DataGrid subclass with auto-filter functionality
-
I'm trying to construct a subclass of the ASP.NET DataGrid with automatical filter functionality. The idea is as follows: The page that uses the DataGrid uses the SetQuery function to tell the grid what It's main query is. This happens in the Page_Load and it splits the query in 2 to seperatie the SELECT ... WHERE clause and the ORDER BY clause... The Grid subclass adds an empty row at the top of the row and puts dynamically created comboboxes in them with all unique values from that column that come from the query. When the user selects an item form one of those comboboxes, the grid refreshes itsself by binding the old query with some self-constructed restrictions... The PROBLEM is that I can't find the right place to do this 'requery'. If I put my code in the OnLoad function it's to early, because the selected value of the combobox isn't known yet. And if I put my code in the selectedIndexChanged event handler of the dynamically created combobox, it's to late to bind the grid, because when I do a DataBind with the new dataset (the dataset is OK!), the old data is still shown on the screen... I've been trying to fix this for about 2 days now, but can't get it to work. It is really important to me that this works, because if it doesn't, I'm going to have to place filters on every page manually instead of using this generic solution. Structured programming vs. chaotic mind boggling