I am trying to access the integer value of the first cell but I'm getting this error:
Unable to cast object of type 'System.Web.UI.WebControls.DataControlFieldCell' to type 'System.IConvertible'.
And the value i have stored in that cell is an ID like 810
My Code
int myID = Convert.ToInt32(GridView1.Rows[rowIndex].Cells[0]);
Cells[0]
returns a DataControlFieldCell
object, not the cell's value.
Use the cell's Text
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With