Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gridview not filtering properly

Status
Not open for further replies.

sajidi99

Programmer
Jun 7, 2005
53
SE
Hello experts,

I have a LinqDataSource bound to ASP.Net GridView which simple displays a table's data in the grid. I have a search button and its code behind like this:

protected void search_Click(object sender, EventArgs e)
{
if (textOrderNumber.Text.Trim() != "")
{
LinqDataSourceOrders.Where = "OrderNumber = " + textOrderNumber.Text;
}
}


This works fine most of the times and it filters the Orders based on order number entered in the text box. The problem is: Sometimes, you have to click search button twice to see the results! My code is really simple and thats all it does what I told you here.

First time you press search, nothing shows! Second time you press search, the related rows appear in the grid!

I am using designer to bind the LinqDataSource to the GridView ... and its simple binding with all default values.

Any ideas what could be wrong? Or how would you do this type of filtering?

Thanks
 
Try binding the grid after the you set the filter.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Tried that but when I bind the grid (gridView.DataBind()), it just takes away the filter and displays full data ... which is not good for me.
 
Sorry, what I meant to write was, I tried that but when I bind the grid (gridView.DataBind()), it makes no difference ... works same as before which is no good for me.

Thanks

Any more ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top