In short:
When visable = false is set for a column in the gridview, data binding is affected and data cannot be obtained. In general, we need to hide the ID column.
Solution:
Specify the following when binding background data:
This. gridview1.datakeynames = new string [] {"ID "};
Or edit datakeynames: ID in the property editor. If two columns need to be hidden and the value is required, separate each field with "," In datakeynames.
Next we will retrieve the data:
If there is only one keyword, that is, datakeynames has only one value, you can use:
This. gridview1.datakeys [E. rowindex]. value. tostring ();
This method is to take the value of the key word with the index 0 in the datakeynames in the current row, that is, the value of the first keyword. Of course, it doesn't matter if there is only one keyword.
You can also use:
This. gridview1.datakeys [E. rowindex] ["ID"]. tostring ();
If there are multiple keywords, you can only use the following method.
Simple record. For future query.