Does these things inside the SelectedIndexChanged event of the DropDownList
First find the row.
Then access the controls and change accordingly.
Pseudo Code
protected void grd_ddlEmp_SelectedIndexChanged(object sender, EventArgs e)
{
GridView row = ((DropDownList)sender).NamingContainer as GridViewRow;
Label Designation = row.FindControl("id of the designation label") as Label;
Designation.Text = "new Designation Name";
}
http://stackoverflow.com/questions/8383112/set-selected-value-of-dropdown-list-in-gridview-rowediting
<Columns>
<asp:BoundField DataField="fid" HeaderText="fid" />
<asp:BoundField HeaderText="Fname" DataField="fname"/>
<asp:TemplateField HeaderText="rname">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" Style="position: relative" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="price" />
<asp:TemplateField HeaderText="Quantity">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Style="position: relative"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField CommandName="addcart" HeaderText="ADDCART" Text="Button" />
</Columns>
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string restaurantname = DropDownList1.SelectedValue.ToString();
SqlCommand price = new SqlCommand("select price from maintable where rid='" + restaurantname + "'", con);
SqlDataAdapter value_price = new SqlDataAdapter(price);
DataSet ds1 = new DataSet();
value_price.Fill(ds1, "Table");
// I need to show the price according to selection of dropdown list
//
}
Premalatha
Software Engineer
Mahe, if this helps please login to Mark As Answer. | Alert Moderator