Datagrid problems

Discussion in '.NET' started by mentalmike, Apr 2, 2008.

  1. mentalmike

    mentalmike

    Joined:
    Apr 2, 2008
    Messages:
    1
    I'm sure this is quite easy to fix but I've spent 2 days trying to find solutions on the internet and can't get it to work.

    I have a page that receives a value and populates a datagrid on page load. This datagrid then has a button column that on the command event of datagrid1 will then populate a second datagrid. This all works as it should. My problem is when I try to then do exactly the same thing with datagrid2 - click on a button and on the command event populate info to datagrid3. What happens is the button is clicked and datagrid2 disappears on the postback and datagrid 3 doesn't appear, all data stays in datagrid1.

    My code is as follows any help would be greatly appreciated.

    Code:
        Dim result_id
        Dim tech
        Dim tech2
        Dim grid2data
        Dim grid3data
    
    
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            result_id = Request.QueryString("id")
            get_overall_data()
        End Sub
    
        Private Sub get_overall_data()
            Dim conn As New OracleClient.OracleConnection
            Dim adapt As New OracleClient.OracleDataAdapter
            Dim ds As New DataSet
    
            conn.ConnectionString = "user id=usr;data source=""database"";password=pass"
            DataGrid1.DataSource = ds
            conn.Open()
            adapt.SelectCommand = New OracleClient.OracleCommand("select this, that from somewhere where result_id = " & result_id & "", conn)
            adapt.Fill(ds)
            DataBind()
            conn.Close()
        End Sub
    
        Public Sub DataGrid1_CommandItem(ByVal source As Object, ByVal e As DataGridCommandEventArgs)
            If e.CommandName = "grid1" Then
                tech = e.Item.Cells(0).Text
                If tech = "1" Then
                    grid2data = "select something1, somethingelse1 from sometable where result_id = " & result_id & ""
                    get_table2_data()
                ElseIf tech = "2" Then
                    grid2data = "select something2, somethingelse2 from sometable where result_id = " & result_id & ""
                    get_table2_data()
                ElseIf tech = "3" Then
                    grid2data = "select something3, somethingelse3 from sometable where result_id = " & result_id & ""
                    get_table2_data()
                Else
                End If
            End If
        End Sub
    
        Private Sub get_table2_data()
            Dim conn As New OracleClient.OracleConnection
            Dim adapt As New OracleClient.OracleDataAdapter
            Dim ds2 As New DataSet
    
            conn.ConnectionString = "user id=usr;data source=""database"";password=pass"
            Datagrid2.DataSource = ds2
            conn.Open()
            adapt.SelectCommand = New OracleClient.OracleCommand(grid2data, conn)
            adapt.Fill(ds2)
            DataBind()
            conn.Close()
        End Sub
    
        Public Sub DataGrid2_CommandItem(ByVal source As Object, ByVal e As DataGridCommandEventArgs)
            If e.CommandName = "grid2" Then
                tech2 = e.Item.Cells(0).Text
                If tech = "PTL1" Then
                    grid3data = "select bing1, bong1 from anothertable where result_id = " & result_id & ""
                    get_table3_data()
                ElseIf tech = "PTL2" Then
                    grid3data = "select bing2, bong2 from anothertable where result_id = " & result_id & ""
                    get_table3_data()
                ElseIf tech = "PTL3" Then
                    grid3data = "select bing3, bong3 from anothertable where result_id = " & result_id & ""
                    get_table3_data()
                Else
                End If
            End If
        End Sub
    
        Private Sub get_table3_data()
            Dim conn As New OracleClient.OracleConnection
            Dim adapt As New OracleClient.OracleDataAdapter
            Dim ds3 As New DataSet
    
            conn.ConnectionString = "user id=usr;data source=""database"";password=pass"
            Datagrid3.DataSource = ds3
            conn.Open()
            adapt.SelectCommand = New OracleClient.OracleCommand(grid3data, conn)
            adapt.Fill(ds3)
            DataBind()
            conn.Close()
        End Sub
    
    End Class
    
     
    mentalmike, Apr 2, 2008
    #1
    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. Ingeborg

    DataGrid problems

    Ingeborg, Jun 28, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    439
    Luke Zhang [MSFT]
    Jul 1, 2003
  2. Susan Baker
    Replies:
    2
    Views:
    823
    kelvSYC
    Jun 26, 2005
  3. Shelly

    Problems, problems for newbie

    Shelly, Sep 2, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    2,191
    Shelly
    Sep 3, 2007
  4. Andreas Klemt
    Replies:
    0
    Views:
    313
    Andreas Klemt
    Oct 8, 2003
  5. Sak Na rede
    Replies:
    0
    Views:
    425
    Sak Na rede
    Jan 30, 2009
Loading...

Share This Page