Capturing the content of a DataGrid Cell???

  • Thread starter Thread starter thomaz
  • Start date Start date
T

thomaz

Hi;

How can i store the content of one DataGrid cell in a
String Variable?

Thanks....
 
If you wanted to get those contents when binding, you can use the
ItemDataBound event of the datagrid. One of the arguments is a
DataGridItemEventArgs which we will refer to as "e". Using this you
can reference a cell (0-based index) with the following:


e.Item.Cells[0].Text (with asp:BoundColumn)


or for a control inside of a template column:


((TextBox) e.Item.Cells[0].FindControl("txtStuff")).Text


If you want to do this at another time when you are not binding, then
replace "e" with the datagrid object name and that should do the trick.


Let me know if this helps you.
Thanks,
Ian Suttle
http://www.IanSuttle.com
 

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

Back
Top