c# - How to get reference of DropDownList into codebehind? -
<asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" onrowupdating="gridview1_rowupdating" onrowediting="gridview1_rowediting"> <columns> <asp:templatefield headertext="test"> <edititemtemplate> <asp:updatepanel id="up1" runat="server" updatemode="conditional"> <contenttemplate> <asp:dropdownlist id="dropdownlist1" runat="server" autopostback="true" onselectedindexchanged="dropdownlist1_selectedindexchanged"> <asp:listitem>test1</asp:listitem> <asp:listitem>test2</asp:listitem> <asp:listitem>test3</asp:listitem> </asp:dropdownlist> </contenttemplate> </asp:updatepanel> </edititemtemplate> <itemtemplate> <asp:label id="label1" runat="server" text='<%# bind("ss") %>' /> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="rate"> <edititemtemplate> <asp:updatepanel id="up2" runat="server" updatemode="conditional"> <contenttemplate> <asp:dropdownlist id="dropdownlist2" runat="server" /> </contenttemplate> </asp:updatepanel> </edititemtemplate> <itemtemplate> <asp:label id="label2" runat="server" text="label" /> </itemtemplate> </asp:templatefield> <asp:commandfield showeditbutton="true" /> </columns> </asp:gridview>
how reference of dropdownlist2
in dropdownlist1_selectedindexchanged
when grid in edit mode?
after editing question. can achieve like...
protected void dropdownlist1_selectedindexchanged(object sender, eventargs e) { dropdownlist dropdownlist2 = ((dropdownlist)((dropdownlist)sender).parent.findcontrol("dropdownlist2")); }
Comments
Post a Comment