ItemDataBound event of DataGrid

D

Dave

Hello.
How can I field value in ItemDataBound event of the DataGrid control?
I'm writing:
e.Item.Cells[0].Text;

But this always returns empty string:(

Thank You.
 
K

Karl Seguin

Consider doing e.Item.FindControl("controlId")

like

TextBox txt = (TextBox) e.Item.FindControl("userName");
if (txt != null){
//found it
}

it's less performant but 100% more readable and won't change when you alter
your html code....also, in case ur wondering, [0] is probably blank 'cuz I
believe whitespaces are converted to literals...which makes the [0] method
even more unreliable.

Karl
 

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,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top