user1223444
user1223444

Reputation:

like operator in entitydatasource

I'm using an EntityDataSource in an asp .net form and a Gridview is bound to it. A where clause is used in the entityDataSource:

Where="it.Name like '%@Name%'

@Name is a parameter:

<WhereParameters>
<asp:ControlParameter ControlID="TextBox1" Name="Name" PropertyName="Text" Type="String"  />
</WhereParameters>

But it doesn't work. When I change @Name with a fixed string it works properly, like this:

Where="it.Name like '%ppp%'"

Upvotes: 4

Views: 2996

Answers (2)

fubo
fubo

Reputation: 45947

A empty TextBox should force the EntityDataSource to show all elements

Where="it.Name like '%' + @Name + '%' OR @Name IS NULL"

Upvotes: 1

Adrian Iftode
Adrian Iftode

Reputation: 15663

Where="it.Name like '%' + @Name+ '%'"

Upvotes: 6

Related Questions