Is it possible to get a row value by giving column name when DataTable holds a single row, without iteration.
foreach(DataRow row in dt.Rows)
{
string strCity = row["City"].ToString();
}
Table
I need Something like below without loop when we have only one row,
String cn=row["ColumnName"].ToString()
I want to search that value in DataTable and get the row and column indexes of that value. How Can i accomplish this with datatable? You can use search () to search the table which would then put those matching rows into the table. table.rows ( {search:'applied'} ).indexes () would return the row index of those matching records.
We can use .loc [] to get rows. Note the square brackets here instead of the parenthesis (). The syntax is like this: df.loc [row, column]. column is optional, and if left blank, we can get the entire row.
I just want to search whole datatable (under whole i mean whole table data, ignoring currently applied by search val value) and get row and column indexes. How can i accomplish that? You can just get the data in an array with something like, table.rows ().data (), and iterate through the array to see if it matches.
out_value = out_dt.Rows (0) (“column_name”).ToString Cheers… You can get it two ways either using column name or column index. row (“ColumnName”).Tostring Please let me know if you face any issue.
This is the way:
string Text = dataTable.Rows[0]["ColumnName"].ToString();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With