Datagrid does not respond to any sorting, dataview filtering, or paging events

Discussion in 'ASP .Net Datagrid Control' started by Michelle, Apr 7, 2005.

  1. Michelle

    Michelle Guest

    This is my third VB.NET forum to try and help me with my problems and several people have failed so I am hoping someone here is a TRUE GURU on datagrids!

    I have a datagrid that I bind to a datasource in the page_load event. No problem.
    However, when I try to do ANYTHING to its data, nothing works.

    Problem 1)

    When clicking a dropdown I try to create a dataview based on the value the user selected in the DD and have the filter based on that value....Here is the code.....


    Private Sub ddPQMSGrp_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddPQMSGrp.SelectedIndexChanged

    Dim strSvcValue As String
    strSvcValue = ddPQMSGrp.SelectedItem.Text

    Dim dv As New DataView(DataSet151.Tables("Products"))
    dv.Table = DataSet151.Products
    dv.RowFilter = "[ItemCode (SAP)] = 'strSvcValue'"
    DataGridProd.DataSource = dv
    DataGridProd.DataBind()

    My dataview finds no records matching my filter criteria (which I know exists in the table and the debugger shows that my variable 'strSvcValue' contains the correct value)

    Problem 2)
    The datagrids property is set to Allow Sorting. My code is as follows...

    Private Sub DataGridProd_SortCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs)
    DataGridProd.DataSource = DataSet151.Products.DefaultView
    DataSet151.Products.DefaultView.Sort = e.SortExpression
    DataGridProd.DataBind()
    End Sub

    Nothing happens to the datagrid...the data does not change.

    Problem 3)
    I cannot click on the numbers at the bottom of the datagrid to page through the records. I have the AllowPaging set to true and have selected 30 records to display on each page. My code is as follows.....

    Private Sub DataGridProd_PageIndexChanged(ByVal source As System.Object,
    ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs)
    DataGridProd.CurrentPageIndex = e.NewPageIndex
    DataGridProd.DataBind()

    End Sub

    The data on the datagrid does not change.

    Someone, please help me. All of my code basically comes from MS tutorials, my ASP.net class, the Visual Studio help files with sample code, etc. I have even tried using different tables and different databases but every datagrid acts the same (eg, no changes allowed!!) I"M CONSIDERING A SMALL REWARD FOR THE PERSON WHO CAN HELP ME:)

    From http://www.developmentnow.com/g/12_2005_2_0_0_0/dotnet-framework-aspnet-datagridcontrol.ht

    Posted via DevelopmentNow.com Group
    http://www.developmentnow.com
    Michelle, Apr 7, 2005
    #1
    1. Advertising

  2. Michelle

    Elton Wang Guest

    Hi Michelle,

    About your Questions:

    Problem 1)

    Change
    dv.RowFilter = "[ItemCode (SAP)] = 'strSvcValue'"
    to
    dv.RowFilter = "[ItemCode (SAP)] = '" + strSvcValue + "'"

    Problem 2)

    You can try
    Dim dv As DataView = DataSet151.Tables
    ("Products").DefaultView
    dv.Sort = e.SortExpression
    DataGridProd.DataSource = dv
    DataGridProd.DataBind()


    Problem 3)

    What do you mean 'cannot click on the numbers'?

    Anywany, code should be

    DataGridProd.CurrentPageIndex = e.NewPageIndex
    DataGridProd.DataSource = yourDataSource
    DataGridProd.DataBind()

    HTH

    Elton Wang



    >-----Original Message-----
    >This is my third VB.NET forum to try and help me with my

    problems and several people have failed so I am hoping
    someone here is a TRUE GURU on datagrids!
    >
    >I have a datagrid that I bind to a datasource in the

    page_load event. No problem.
    >However, when I try to do ANYTHING to its data, nothing

    works.
    >
    >Problem 1)
    >
    >When clicking a dropdown I try to create a dataview based

    on the value the user selected in the DD and have the
    filter based on that value....Here is the code.....
    >
    >
    > Private Sub ddPQMSGrp_SelectedIndexChanged(ByVal sender

    As System.Object, ByVal e As System.EventArgs) Handles
    ddPQMSGrp.SelectedIndexChanged
    >
    > Dim strSvcValue As String
    > strSvcValue = ddPQMSGrp.SelectedItem.Text
    >
    > Dim dv As New DataView(DataSet151.Tables

    ("Products"))
    > dv.Table = DataSet151.Products
    > dv.RowFilter = "[ItemCode (SAP)] = 'strSvcValue'"
    > DataGridProd.DataSource = dv
    > DataGridProd.DataBind()
    >
    >My dataview finds no records matching my filter criteria

    (which I know exists in the table and the debugger shows
    that my variable 'strSvcValue' contains the correct value)
    >
    >Problem 2)
    >The datagrids property is set to Allow Sorting. My code

    is as follows...
    >
    > Private Sub DataGridProd_SortCommand(ByVal source As

    System.Object, ByVal e As
    System.Web.UI.WebControls.DataGridSortCommandEventArgs)
    > DataGridProd.DataSource =

    DataSet151.Products.DefaultView
    > DataSet151.Products.DefaultView.Sort =

    e.SortExpression
    > DataGridProd.DataBind()
    > End Sub
    >
    >Nothing happens to the datagrid...the data does not

    change.
    >
    >Problem 3)
    >I cannot click on the numbers at the bottom of the

    datagrid to page through the records. I have the
    AllowPaging set to true and have selected 30 records to
    display on each page. My code is as follows.....
    >
    >Private Sub DataGridProd_PageIndexChanged(ByVal source As

    System.Object,
    > ByVal e As

    System.Web.UI.WebControls.DataGridPageChangedEventArgs)
    > DataGridProd.CurrentPageIndex = e.NewPageIndex
    > DataGridProd.DataBind()
    >
    > End Sub
    >
    >The data on the datagrid does not change.
    >
    >Someone, please help me. All of my code basically comes

    from MS tutorials, my ASP.net class, the Visual Studio
    help files with sample code, etc. I have even tried using
    different tables and different databases but every
    datagrid acts the same (eg, no changes allowed!!) I"M
    CONSIDERING A SMALL REWARD FOR THE PERSON WHO CAN HELP ME:)
    >
    >
    >From

    http://www.developmentnow.com/g/12_2005_2_0_0_0/dotnet-
    framework-aspnet-datagridcontrol.htm
    >
    >Posted via DevelopmentNow.com Groups
    >http://www.developmentnow.com
    >.
    >
    Elton Wang, Apr 8, 2005
    #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. Marco Ippolito
    Replies:
    2
    Views:
    3,198
    Marco Ippolito
    May 19, 2004
  2. Jason
    Replies:
    1
    Views:
    485
    Jason
    Aug 31, 2004
  3. Patrick Olurotimi Ige

    DataView Sorting with Paging Question

    Patrick Olurotimi Ige, Dec 9, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,990
    Patrick Olurotimi Ige
    Dec 9, 2004
  4. CodeMonkey
    Replies:
    1
    Views:
    725
    joyal jhaveri
    Feb 4, 2011
  5. Ryan Liu
    Replies:
    0
    Views:
    127
    Ryan Liu
    Dec 12, 2008
Loading...

Share This Page