if (result == null || result.ToList().Count == 0)
{
// Display message
}
ASP.NET and Entity Framework Check The Result is Empty Or Not
-
18-10-2022 - |
Question
Using code like this:
AppEntities data = new AppEntities();
var result = data.GIS_CONTRACTOR_TEST.Where(x => x.CONTRACTORNAME == txtSearch.Text);
GridView1.DataSource = result.ToList();
GridView1.DataBind();
I am able to filter data based on the text box. now my question is How I can check if the result
is empty or not? I mean if I want to send a message to user that there is not such a value in the database? how can I do that?
Thanks
Solution
OTHER TIPS
You mean outside asking the list whether it has a length of 0? WHich would be the obvious thing to do?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow