asp.net - Text box inside a grid view not showing data -
i adding text box inside grid view.
when user clicks add button new text box created.
i getting data text boxes, when add data text boxes showing nothing
private void setprevioustids(datatable dt) { if (viewstate["tidtable"] != null) { if (dt.rows.count > 0) { (int = 0; < dt.rows.count; i++) { textbox tid = (textbox)gridview1.rows[i].cells[0].findcontrol("tid"); response.write(tid.text.tostring()); tid.text = "hello";// text not showing on text box } } } } aspx code here
<asp:gridview id="gridview1" runat="server" visible="true"> <columns> <asp:templatefield headertext="tid"> <itemtemplate> <asp:textbox id="tid" runat="server"></asp:textbox> </itemtemplate> <footertemplate> <asp:button id="buttonadd" runat="server" text="+" onclick="add_tid" /> </footertemplate> </asp:templatefield> </columns> </asp:gridview>
you'll want this:
protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { textbox mytextbox = (textbox)(e.row.cells[1].findcontrol("tid")); mytextbox.text == "hello"; } }
Comments
Post a Comment