c# - Getting textbox's value in Nested gridview -
i have nested gridview, , there textbox named textboxdescription insert user information in second gridview. when want catch textbox's (textboxdescription) value return null.
html code:
<asp:gridview id="gridview1" runat="server" autogeneratecolumns="false" width="100%" datakeynames="reportid" onrowdatabound="gridview2_onrowdatabound" forecolor="#333333"> <alternatingrowstyle backcolor="white" forecolor="#284775" /> <columns> <asp:templatefield> <itemstyle width="35px" horizontalalign="center" /> <itemtemplate> <img alt="" style="cursor: pointer" src="plus.png" /> <asp:panel id="panel5" runat="server" style="display: none; text-align: center;"> <asp:gridview id="gridview2" border="0" runat="server" datakeynames ="reportid" onrowcommand="gridview1_rowcommand" style="direction: rtl" width="100%" height="100%"> <columns> <asp:templatefield> <itemtemplate> <table width="100%" height="100%" bgcolor="#f4f4f4"> <tr> </tr> <tr> <td style="width: 50%; height: 50%" hidefocus="hidefocus" unselectable="off" valign="top"> <asp:panel id="panel3" runat="server" groupingtext="یاد داشت"> <asp:textbox id="textboxdescription" runat="server" style="resize: none; width: 612px; height: 160px;" text='<%# eval("userdescription") %>' textmode="multiline"></asp:textbox> <br /> <br /> <asp:linkbutton id="linkbuttonsave" commandname ="updatedata" commandargument='<%#eval("reportid") %>' runat="server">ذخیره</asp:linkbutton> </asp:panel> </td> </tr> </table> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> . . .
c# code:
protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { if (e.commandname == "updatedata") { int = convert.toint32(e.commandargument); gridviewrow row = (gridviewrow)(((linkbutton)e.commandsource).namingcontainer); textbox tb = (textbox)row.findcontrol("textboxdescription"); string text = tb.text; } }
do below :
gridviewrow row = (gridviewrow)(((linkbutton)e.commandsource).namingcontainer); int index = row.rowindex; textbox tb= (textbox )gridview1.rows[index].findcontrol("textboxdescription");
Comments
Post a Comment