Datagrid problems

Joined
Apr 2, 2008
Messages
1
Reaction score
0
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
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top