<Asp: templatefield visible = "false">
<Itemtemplate>
<Asp: Label id = "lblgoodsid" runat = "server" text = '<% # BIND ("cgoodsid") %>'> </ASP: Label>
</Itemtemplate>
</ASP: templatefield>
<Asp: boundfield datafield = "cgoodsid" visible = "false"/>
Protected void onupdate (Object sender, eventargs E)
{
Gridviewrow t = (gridviewrow) (imagebutton) sender). Parent. Parent );
Label lblgoodsid = (Label) T. findcontrol ("lblgoodsid ");
Response. Write (lblgoodsid. Text );
Response. Write (T. cells [1]. Text );
}
The same is visible = "false". The first one can be printed. The second one is not printed.
If you want to hide unnecessary columns in the gridview control, you cannot obtain the value of this column after using visible = "false.
The solution is simple:
--------------------------------------------------
Protected void gridview1_rowdatabound (Object sender, gridviewroweventargs E)
{
// Hide unnecessary Columns
If (E. row. rowtype = datacontrolrowtype. datarow) | (E. row. rowtype = datacontrolrowtype. header) | (E. row. rowtype = datacontrolrowtype. footer ))
{
E. Row. cells [0]. Visible = false;
E. Row. cells [3]. Visible = false;
}
}