I'm getting schema info but not so far able to bind it into datagrid columns, see code below I can print out the column-name and description and want to bind those into data grid columns

Dim schemaTable = dbConn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, _
                          New Object() {Nothing, Nothing, "VolDataNew", Nothing})
       
        For i = 0 To schemaTable.Rows.Count - 1
            Response.Write("i = " & i & "  " & schemaTable.Rows(i)!COLUMN_NAME.ToString & " IS " & schemaTable.Rows(i)!DESCRIPTION.ToString & "<br/>")
            gridTable.Rows.Add(schemaTable.Rows(i)!COLUMN_NAME.ToString, schemaTable.Rows(i)!DESCRIPTION.ToString)
        Next i

        grid1.DataSource = schemaTable
        grid1.DataBind()


when i bind with the code below, I get all the columns from the table

<asp:Datagrid ID="grid1" runat="server" >
        <Columns>
            <asp:TemplateColumn HeaderText="DESCRIPTION" >
                <ItemTemplate>
                    <asp:Label ID="desc"
                               text='<%# DataBinder.Eval(Container.DataItem,"DESCRIPTION") %>'
                               runat="server" />

see rendered table in the attachment I want to only bind the COLUMN_NAME + DESCRIPTION table info into columns

I even tried creating a 2 column table, moving the the 2 columns to it, and binding that but it still rendered all the table columns, which seems really weird.

Recommended Answers

All 2 Replies

Turn off auto generated columns property.

thanks, that was so easy
I got the message about using code brackets in the future, will do

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.