Question gridview with multiple tables

opie

Member
Joined
Apr 2, 2010
Messages
8
Programming Experience
Beginner
I'm trying to run a query on a oracle database using a join or union or multiple tables. Store that information into a reader then bind it to a dataset and fill a gridview. I might be going about this all wrong but it works with a single table, just not when I query two tables

I make my connection fine with ODBCCOnnection

VB.NET:
 Dim ODistConStr As String = "Driver={Microsoft ODBC for Oracle};Server=" etc etc"
Dim ODistdbCon As New Odbc.OdbcConnection(ODistConStr)

then I create my query

VB.NET:
Dim query as String = "select a.column1, b.column1, a.column2 from table1 inner join table2 on a.column1 = b.column2
Dim sqlCmd As New Odbc.OdbcCommand(query, ODistdbCon)
Dim reader As Odbc.OdbcDataReader = sqlCmd.ExecuteReader()

reader.fill(ds, "table1")
Me.Gridview.Datasource = ds
Me.GridView1.DataBind()

I'm getting all the columns i want from table 1 but none from table 2.

How do I go about getting table 2 in the gridview if possible?
 
Last edited:
Aha. I got it. Not 100% what this means have to do some research but

VB.NET:
    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Or e.Row.RowType = DataControlRowType.Header Then
            'e.Row.Cells(1).Attributes.Add("style", "width: 50px;")
            e.Row.Cells(1).Visible = True
            e.Row.Cells(2).Width = 30
        End If
    End Sub

the e.Row.Cells(1) was set to False. changing to true and everything shows up
 
the e.Row.Cells(1) was set to False. changing to true and everything shows up

I assume that you mean e.Row.Cells(1).Visible was set to False. Are you saying that it was set to False by default or that your code was previously setting it to False? If it's the latter then the issue is fairly obvious. If it's the former then I'm not sure why that would be the case and I have no experience with the GridView control that might help.
 
I assume that you mean e.Row.Cells(1).Visible was set to False. Are you saying that it was set to False by default or that your code was previously setting it to False? If it's the latter then the issue is fairly obvious. If it's the former then I'm not sure why that would be the case and I have no experience with the GridView control that might help.

yes it was set to false. I probably did it at some point but I don't remember why. Also why would Row Cells be invisible and it affected a column in the gridview. That was all I was saying I needed to research
 

Latest posts

Back
Top