Grid View Row Value

C

CK

How can I get this value at runtime? I want the value of the row as it's
created. Any ideas?
 
E

Eliyahu Goldin

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.
 
C

CK

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?
 
E

Eliyahu Goldin

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top