Similarities and differences between visible = "false" in the gridview Column

Source: Internet
Author: User

<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;

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.