i has the form of a grid in the form and has some template field, one of which:
<asp:TemplateField HeaderText="Country" HeaderStyle-HorizontalAlign="Left"> <EditItemTemplate> <asp:DropDownList ID="DdlCountry" runat="server" DataTextField="Country" DataValueField="Sno"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField>
Now in the RowEditing event I need to get the selected dropdownlist value of the country, and then I will set this value as Ddlcountry.selectedvalue = value; so when the drop-down list of the template for the edit item appears, it will show the selected value, not index 0 from the drop-down list. but I can not get the value of the dropdown list. I have already tried this:
int index = e.NewEditIndex; DropDownList DdlCountry = GridView1.Rows[index].FindControl("DdlCountry") as DropDownList;
need help please. Thanx.
Mogli
source share