2

I retrieve keywords from a textbox and want to refresh a GridView that is bound to a LinqDataSource.

I assume I can do this in the OnTextChanged function as follows

    protected void OnTextChanged(object sender, EventArgs e)
    {
     // do LINQ query based on content in textbox
     catalogDataContext dc = new catalogDataContext();
     var query = from product in dc.catalog
                 where product.Name.Contains(TextBox.Text)
                 select product;     

     // what do I have to do here to refresh the GridView? Thanks.


    GridView.DataBind();
    }
1
  • 1
    Did you try it? It worked, right?
    – drdwilcox
    Nov 18, 2011 at 0:13

1 Answer 1

0

Use your linq source's databind method to refresh data context first. Then use gridView's databind method to refresh grid view to new context. TIP: if you want, put your gridView in AJAX update panel - the resulting page is much better that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.