Can't access control in footer of ASP.Net Gridview -
by company mandate. have gridview footertemplate, , in template have textbox.
when go access in code behind, it's coming not found. kind of scope issue? shouldn't code behind have access fields in gridview?
<footertemplate> <asp:textbox name="txtid" controlid="cntid" width="20" runat="server"></asp:textbox> </footertemplate>
.
insert.parameters.addwithvalue("@id", txtid not found .....
when nest 1 control inside another, it's best use parent control's findcontrol()
method. also, need give control id attribute, not name.
<footertemplate> <asp:textbox id="txtid" controlid="cntid" width="20" runat="server"></asp:textbox> </footertemplate>
.
insert.parameters.add("@id", sqldbtype.nvarchar, 50).value = gridview1.footerrow.findcontrol("txtid").text
and if you're curious, here's why switched away addwithvalue()
Comments
Post a Comment