Search code examples
asp.netgridviewlinqdatasource

Where condition in LinqDataSource for string in ASP.NET


I am trying to populate data in gridview by using LinqDataSource and in the where condition of LinqDataSource1 - programmatically I am not sure about the syntax on how to pass a string value to a particular column?

What is the syntax for where condition in LinqDataSource on a string programmatically?

I am familiar with the one in int:

 int id = 5; 

for example:

LinqDataSource1.Where = "ID =" +id;

But, not sure about the syntax for string.

Please suggest something!


Solution

  • Ok, finally I got the syntax for string in LinqDataSource:

    LinqDataSource1.Where = "Title.Contains("+ "\"" + txtTitle.Text + "\""+ ")";