Last post Jun 12, 2020 03:27 AM by XuDong Peng
Jun 11, 2020 04:15 PM|mazharul007|LINK
let I have a table called test and another table called
I got a value (row) from table test which is
Now i want to check and compare that if there is any row called rollNo exists in my testTwo table.
How can i do this in asp.net? Thanks.
I am adding some sample code here to get the concept that what i am trying to do.
int? rollNO = null;
if (((DataRowView)e.Item.DataItem).Row["rollNO"].ToString() != null && ((DataRowView)e.Item.DataItem).Row["rollNO"].ToString().Trim().Length > 0)
if (((DataRowView)e.Item.DataItem).Row["IsActiveStatus"].ToString() == "False")
if (here i want to check that if rollNO row exists in testTwo table)
item.CssClass = "Green" + " rgRow";
item.CssClass = "Red" + " rgRow";
Jun 11, 2020 05:24 PM|mgebhard|LINK
Usually this type of logic is handled in SQL with a basic SQL JOIN or SELECT. The result set is passed to the data bound control where you can do with the result set as you please.
Jun 12, 2020 03:27 AM|XuDong Peng|LINK
According to your description, do you want to determine whether a column is included in the data set?
If so, I think you maybe use :
private void ContainColumn(string columnName, DataTable table)
DataColumnCollection columns = table.Columns;
More details, please refer DataColumnCollection.Contains(String) Method.
Before this, I think you have got the data of the testTwo table.
Hope this can help you.