How to hide a column (GridView) but still access its value?

后端 未结 13 1282
粉色の甜心
粉色の甜心 2020-11-27 17:52

I have a GridView with a DataSource (SQL Database). I want to hide a column, but still be able to access the value when I select the record. Can someone show me

13条回答
  •  死守一世寂寞
    2020-11-27 18:29

    If you do have a TemplateField inside the columns of your GridView and you have, say, a control named blah bound to it. Then place the outlook_id as a HiddenField there like this:

    
        
            Existing Control
            
        
    
    

    Now, grab the row in the event you want the outlook_id and then access the control.
    For RowDataBound access it like:

    string outlookid = ((HiddenField)e.Row.FindControl("HiddenOutlookID")).Value;
    

    Do get back, if you have trouble accessing the clicked row. And don't forget to mention the event at which you would like to access that.

提交回复
热议问题