Groups | Blog | Home
all groups > asp.net datagrid control > october 2003 >

asp.net datagrid control : rowfilter in datagrid


Bill Greenley
10/10/2003 9:49:07 AM
I'm trying to use the rowfilter property to limit the rows displayed in a
detail datagrid based on the row selected in a master grid. Here's a code
snippet from the initial display of the grids where I "preselect" the first
row of the master grid to populate the detail grid.

As you can see below I tried it with a dataview and then simply set the
rowfilter on the defaultview. I show the filter in a label and it is what I
expect. Key is a long integer here. The problem is that ALL the detail
records are displayed regardless of the filter. I have similar code for the
MasterGrid SelectedIndexChanged which gets the Key from the selected row.
In this case the debug display shows an expected rowfilter, but after
re-databinding the detail grid, zero rows are shown.

I fill the dataadapter only once (Stored Procedure that brings down all 4
_small_ tables) after entering a couple text boxes and clicking a command
button. I do nothing at all in Page_Load.

What am I doing wrong??? tia
Dim Key As String = dgPars.DataKeys(0).ToString()
Dim strFilter As String
Me.lbl1.Text = "SvcId:" & Key 'for debug
'populate detail grid
Dim dvEvents As New DataView
dvEvents = DsSHistory.Tables("LitEvents").DefaultView
strFilter = "([Service Id]=" & Key & ")"
dvEvents.RowFilter = strFilter
DsSHistory.Tables("LitEvents").DefaultView.RowFilter = strFilter
'dgEvents.DataSource = dvEvents
dgEvents.DataBind()

Bill Greenley
10/13/2003 3:42:44 PM
My bad. I still had the datasource and datamember set from populating the
columns. Even though I set the datasource here, the datamember setting
appeared to prevail. After clearing the datasource and datamember in the
datagrid property, this code worked.

[quoted text, click to view]

AddThis Social Bookmark Button