Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

EntityDataSource add parameter and paging

$
0
0

I have ListView with paging and EntityDataSource. ListView should show all items from database but If in url we have for example phrase 'cat' it should show only items with phrase 'cat' in Title so I have:

public partial class List : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["phrase"] != null)
        {
            EntityDataSource1.WhereParameters.Add("Phrase", TypeCode.String, Request.QueryString["phrase"].ToString());
            EntityDataSource1.Where = "it.Title like '%' + @Phrase + '%'";
        }
    }
}

But when I go to next page I have error:

Parameter name "Phrase" already exists in the parameter

collection


Viewing all articles
Browse latest Browse all 23244

Trending Articles