c# - Can't retrieve value from template field -


im trying value templatefield id in gridview.

<itemtemplate>    <asp:label id="lblid" runat="server" text='<%# bind("cr_id") %>'></asp:label> </itemtemplate> 

i need retrieve id update it. following codes aspx.cs

 gridview mygrid = (gridview)sender; // gridview         label lblprodid = (label)mygrid.findcontrol("lblid");         string colid = lblprodid.tostring();   bllcredentials updateid = new bllcredentials();             int ds;             ds = updateid.updstatus(colid, 1);             gv_credentialslist.editindex = -1;             bind();             sendemail(); 

the error

object reference not set instance of object.

description: unhandled exception occurred during execution of current web request.

please review stack trace more information error , originated in code.

exception details: system.nullreferenceexception: object reference not set instance of object.

you can find control inside gridview itemtemplate like

label lblprodid = (label )mygrid.rows[0].cells[0].findcontrol("lblid"); 

rows[put row index] , cells[put cell index]


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -