Grid View Row Value

  • Thread starter Thread starter CK
  • Start date Start date
Look at RowDataBound event. It fires for every grid row as it gets
databound, in other words gets populated. The row object is available in
event parameters.
 
I can get a handle on on the row and I can look at
e.Row.DataItem.Row.ItemArray, is there a shorter property i can use to get
the datakey value of the row? Thanks for your help.

~Ck

Eliyahu Goldin said:
Look at RowDataBound event. It fires for every grid row as it gets
databound, in other words gets populated. The row object is available in
event parameters.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

CK said:
How can I get this value at runtime? I want the value of the row as it's
created. Any ideas?
 
If you want the value as it comes to the grid view, use e.Row.Cells
collection.

If you want the value as it is in the database, typecast e.Row.DataItem to
your datasource row type. For datatable it will be
(DataRowView)e.Row.DataItem.

If you need to get the datakey value for a row, you don't need to do it in
the RowDataBound event. Use
myGridView.DataKeys[rowNumber].Value
after the whole gridview is databound.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


CK said:
I can get a handle on on the row and I can look at
e.Row.DataItem.Row.ItemArray, is there a shorter property i can use to get
the datakey value of the row? Thanks for your help.

~Ck

Eliyahu Goldin said:
Look at RowDataBound event. It fires for every grid row as it gets
databound, in other words gets populated. The row object is available in
event parameters.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

CK said:
How can I get this value at runtime? I want the value of the row as it's
created. Any ideas?
 
Back
Top