How to get a datarow from a datable in C#?
-
:) I have a datatable which is having n no. of rows and each row has a unique field say ID. Now I want to get a particular row for a specified ID. eg. there are 5 rows in a datatable and the id's are 1,2,3,4 and 5 and if I want to select a row having ID = 4 What will be the code snippet for that? Does anybody have any idea? Thanks in advance,
-
:) I have a datatable which is having n no. of rows and each row has a unique field say ID. Now I want to get a particular row for a specified ID. eg. there are 5 rows in a datatable and the id's are 1,2,3,4 and 5 and if I want to select a row having ID = 4 What will be the code snippet for that? Does anybody have any idea? Thanks in advance,
IF your datatable hasn't got too many rows you could o the trick with: foreach (DataRow row in dataTable.Rows) { if (row["ID"].Equals(4)) { } }
-
IF your datatable hasn't got too many rows you could o the trick with: foreach (DataRow row in dataTable.Rows) { if (row["ID"].Equals(4)) { } }
You can do it like this dataTable.rows[4]["ColumName"].tostring()
-
:) I have a datatable which is having n no. of rows and each row has a unique field say ID. Now I want to get a particular row for a specified ID. eg. there are 5 rows in a datatable and the id's are 1,2,3,4 and 5 and if I want to select a row having ID = 4 What will be the code snippet for that? Does anybody have any idea? Thanks in advance,