Вопрос

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

Это было полезно?

Решение

if (result == null || result.ToList().Count == 0)
{
  // Display message
}

Другие советы

You mean outside asking the list whether it has a length of 0? WHich would be the obvious thing to do?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top