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

RadGrid Binding through DataTable

3 Answers 522 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Susi
Top achievements
Rank 1
Susi asked on 17 Nov 2012, 05:44 PM
Hi..
i am binding grid through data table through chart serious click event and set autogeneratecolumns="true" in grid at aspx page and also i didn't apply any code 'gridbound colum & gridtemplate column' like that based on datatable column and rows grid will be generated.
when i click first time in chart serious grid will be generated correctly but second time grid style will be changed in column header and overall structure.. what i want to do be grid same every time i execute this.
and my coding are mentioned below kindly guide me to solve this..

aspx code is

<telerik:RadGrid id="radgrid1" ruunat="server" autogeneratecolumn="true">
<headerstyle horizantalalign="left"/>
</telerik:RadGrid>

aspx.cs code is

DataTable table1=getdata();
radgrid1.datasource=table1;
radgrid1.databound();


thanks in advance..!

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Nov 2012, 05:40 AM
Hello,

If possible then can you please provide some part of your code?

Thanks,
Jayesh Goyani
0
Susi
Top achievements
Rank 1
answered on 19 Nov 2012, 06:56 AM
Hi
my codings are mentioned below.

<telerik:RadGrid ID="rad_grd_ComponentDrillThorugh" runat="server"
                                     CellSpacing="0" GridLines="None" AutoGenerateColumns="true">
                                     <HeaderStyle HorizontalAlign="Left" />
                                     <MasterTableView>
                                     </MasterTableView>
                                     </telerik:RadGrid>

private void BindDrillDownGrid(int componentId, DateTime date, int shiftNumber)
       {
           DataTable dtSource = dashboard.LT_00008_LAEMI_FN_Daybasedproductiondetailsondate(componentId, date, shiftNumber);
           rad_grd_ComponentDrillThorugh.DataSource = dtSource;
           rad_grd_ComponentDrillThorugh.DataBind();
       }

thanks,


0
Jayesh Goyani
Top achievements
Rank 2
answered on 21 Nov 2012, 05:20 AM
Hello,


<telerik:RadGrid ID="rad_grd_ComponentDrillThorugh" runat="server" CellSpacing="0"
            GridLines="None" AutoGenerateColumns="true"
            onneeddatasource="rad_grd_ComponentDrillThorugh_NeedDataSource">
            <HeaderStyle HorizontalAlign="Left" />
            <MasterTableView>
            </MasterTableView>
        </telerik:RadGrid>
protected void rad_grd_ComponentDrillThorugh_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
   {
       DataTable dt = new DataTable();
       dt.Columns.Add("Shipper", typeof(string));
       dt.Columns.Add("ShipDate", typeof(DateTime));
       dt.Rows.Add("Shipper1", DateTime.Now.AddDays(1));
       dt.Rows.Add("Shipper2", DateTime.Now.AddDays(2));
       dt.Rows.Add("Shipper3", DateTime.Now.AddDays(3));
       dt.Rows.Add("Shipper1", DateTime.Now.AddDays(1));
       dt.Rows.Add("Shipper2", DateTime.Now.AddDays(2));
       dt.Rows.Add("Shipper3", DateTime.Now.AddDays(3));
       rad_grd_ComponentDrillThorugh.DataSource = dt;
   }



Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Susi
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Susi
Top achievements
Rank 1
Share this question
or