rowfilter in datagrid

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

Bill Greenley

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top