ASP.NET get cell from DataRow in a datatable? -


i wondering how access cells in datatable? thought like

  foreach (datarow siterow in sites.rows)         {             string sitename = siterow.cells[1].text;         } 

but doesn't seem work gridview. should do?

use indexer:

foreach (datarow siterow in sites.rows) {     string sitename = siterow[1].tostring(); // second column     // or via name:     sitename = siterow["sitename"].tostring; // if column name sitename     // or better via field method typed      // , supports nullable types:     sitename = siterow.field<string>(1); // works via name } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -