Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8256817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:59:18+00:00 2026-06-08T01:59:18+00:00

In the code-behind I want to apply a dynamic where clause for the entitydatasource,

  • 0

In the code-behind I want to apply a dynamic where clause for the entitydatasource, but I want this where to be like and not equal. I have this code working which is equal I want an equivalence code that somehow translates this into a Like statement.

EntityDataSource1.WhereParameters.Add("Name", TypeCode.String, tbxSearch.Text);

Solution after reading Jupaol comment :

Xaml:

<WhereParameters>
   <asp:ControlParameter ControlID="tbxSearch" Name="Name" Type="String" />
</WhereParameters>

Code Behind: (on load event)

if (string.IsNullOrEmpty(tbxSearch.Text))
{
   this.EntityDataSource1.Where = "1=1";  //fetch all data if empty
}
else
{
   this.EntityDataSource1.Where = "it.Name like '%' + @Name + '%'"; //filter
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:59:21+00:00Added an answer on June 8, 2026 at 1:59 am

    In that code you are only adding a parameter, the place where you need to define your like comparison, is in the where clause

    The code you posted can be translated into:

        <asp:EntityDataSource runat="server" ID="eds"
            .....
            Where="it.fname like '%' + @Name + '%'"
            <WhereParameters>
                <asp:ControlParameter ControlID="tbxSearch" Name="Name" DefaultValue="" />
            </WhereParameters>
    

    To Add the where in code behind:

    this.eds.Where = "it.fname like '%' + @Name + '%'";
    

    Edit1:

    For some reason, if I place the parameter declaration like yours (in code), it is not working, however if I place the parameter in the markup like this:

            <WhereParameters>
                <asp:ControlParameter ControlID="tbxSearch" Name="Name" Type="String" DefaultValue="" />
            </WhereParameters>
    

    And in Page_Load

    this.eds.Where = "it.fname like '%' + @Name + '%'";
    

    It works

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to create a validatior via code behind.But although i create it,it doesnt
I want to create an item to sitecore using code behind. I found this
I want to add a DependencyObject to a control from code behind. I have
From my page's code-behind I want to access the value of this hidden field.
I have a boolean property in code-behind ASP.NET, now I want to use it
net/C# application I have list of items. In the code behind: I want to
I have two grids inside a TabItem and in the code-behind I want to
I have a public property in my code-behind that I want to bind it
I'm writing a WPF application with C# as the code behind and I want
I want to use Container.ItemIndex in my Code Behind in my function in OnCustomColumnDisplayText

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.