This is a migrated thread and some comments may be shown as answers.

DataTable and RadGrid

1 Answer 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tonya
Top achievements
Rank 1
Tonya asked on 09 Oct 2012, 03:11 PM
I am trying to assign the datasource from a DataTable.  The data table gets filled from the DB, but nothing shows up on the radgrid, not even column names.  



protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            LoadGrid1();
        }
private
void LoadGrid1()
        {
            string sql = GetSQL();
            DB2Connection connection = new DB2Connection(WebConfigurationManager.ConnectionStrings["TX"].ConnectionString);
            DB2DataAdapter dataAdapter = new DB2DataAdapter(sql, connection);
            DataTable dataTable = new DataTable();
            using (connection)
            {
                dataAdapter.Fill(dataTable);
            }
            RadGrid1.DataSource = dataTable;
        }
<telerik:RadGrid
                ID="RadGrid1"
                runat="server"
                AllowPaging="true"
                AllowFilteringByColumn="true"
                AutoGenerateColumns="false"
                PageSize="20"
                OnNeedDataSource="RadGrid1_NeedDataSource"
                OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged">
            <MasterTableView DataKeyNames="invoice_id">
                <Columns>
                    <telerik:GridButtonColumn
                        Text="Details"
                        CommandName="Select" />
                    <telerik:GridBoundColumn 
                        DataField="invoice_id"
                        HeaderText="Invoice ID" />
                    <telerik:GridBoundColumn 
                        DataField="x12_id"
                        HeaderText="X12 ID" />
                    <telerik:GridBoundColumn 
                        DataField="st_id"
                        HeaderText="ST ID" />
                    <telerik:GridBoundColumn 
                        DataField="invoice_num"
                        HeaderText="Invoice #" />
                    <telerik:GridBoundColumn 
                        DataField="invoice_dt"
                        HeaderText="Invoice Date"
                        DataFormatString = "{0:MM/dd/yyyy}" />
                    <telerik:GridBoundColumn 
                        DataField="po_num"
                        HeaderText="PO #" />
                    <telerik:GridBoundColumn 
                        DataField="po_dt"
                        HeaderText="PO Date"
                        DataFormatString = "{0:MM/dd/yyyy}" /> 
                    <telerik:GridBoundColumn 
                        DataField="vendor_id"
                        HeaderText="Vendor ID" /> 
                    <telerik:GridBoundColumn 
                        DataField="vendor_duns"
                        HeaderText="Vendor DUNS #" />
                    <telerik:GridBoundColumn 
                        DataField="user_flg1"
                        HeaderText="Type" />
                    <telerik:GridBoundColumn 
                        DataField="user_flg2"
                        HeaderText="EDI Type" />
                    <telerik:GridBoundColumn 
                        DataField="total_amt"
                        HeaderText="Amount" />
                    <telerik:GridBoundColumn 
                        DataField="num_lines"
                        HeaderText="Lines" /> 
                    <telerik:GridBoundColumn 
                        DataField="store_num"
                        HeaderText="Store #" />            
                </Columns>
            </MasterTableView>
            <ClientSettings EnableRowHoverStyle="true" />
        </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 12 Oct 2012, 06:57 AM
Hello,

I tried to replicate the issue you are facing with a sample project, but to no avail. Could you give the project a try and check whether it is working on your end.

Greetings,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Tonya
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or