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

后端 未结 13 1310
粉色の甜心
粉色の甜心 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:09

    Here is how to get the value of a hidden column in a GridView that is set to Visible=False: add the data field in this case SpecialInstructions to the DataKeyNames property of the bound GridView , and access it this way.

    txtSpcInst.Text = GridView2.DataKeys(GridView2.SelectedIndex).Values("SpecialInstructions")
    

    That's it, it works every time very simple.

提交回复
热议问题