rowfilter in datagrid

Discussion in 'ASP .Net Datagrid Control' started by Bill Greenley, Oct 10, 2003.

  1. 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, Oct 10, 2003
    #1
    1. Advertising

  2. 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.

    >
    > 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, Oct 13, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manoj Paramu Das

    RowFilter on Date field

    Manoj Paramu Das, Apr 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,568
    sachintana
    Apr 21, 2005
  2. Andreas Klemt
    Replies:
    4
    Views:
    19,670
    nabeel
    Apr 19, 2012
  3. Paul Meller

    DataView.Rowfilter String Problem

    Paul Meller, Jan 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    717
    Paul Meller
    Jan 15, 2004
  4. =?Utf-8?B?S3VtYXI=?=

    RowFilter datagrid

    =?Utf-8?B?S3VtYXI=?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,146
    pradeep.knair
    Apr 7, 2008
  5. kumar

    RowFilter property to filter rows in my datagrid

    kumar, Feb 20, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    177
    Alvin Bruney [MVP]
    Mar 2, 2004
Loading...

Share This Page