B
Bill Greenley
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()
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()