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

How to bind the data to the grid with automatic date column generation

1 Answer 86 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Satish asked on 14 Sep 2012, 02:37 PM

        I have a dataset which is attached "Db Results.png" as below.
        Based on the DB results, I'm able to pull the data into screen as "Grid Results as per the DB column names.png".

        But my requirement is, If the user generate a report on Monday 09/17/2012, then he has to see the data for next five days with respective of specified dates.

       If you see the image "Expected Final Grid Results Should looks as like this.png", in that grid, the results are with respective of each date. Please could you help my how I can Acheive it?

Please find the below code:





div id="dvResult" style="min-width: 64%; width: 64%; height: 98%; float: right;">






<asp:UpdatePanel ID="updReportData" runat="server">




<asp:Label ID="lblMetricsInfo" runat="server"></asp:Label></Br>


<asp:Label ID="lblMetricsBusinessInfo" runat="server"></asp:Label>


<div style="text-align: right">


<asp:LinkButton ID="lnkShowAll" Text="Show All" ToolTip="Toggle grid paging" runat="server"


CommandName="CurrentGrid" CommandArgument="ReportData"></asp:LinkButton>


<asp:ImageButton ID="imgToExcel" runat="server" ImageUrl="../images/excel_16x16.png"


AlternateText="Export data to Excel" ToolTip="Export grid data to Excel." Style="width: 16px;



height: 16px; cursor: pointer;" CommandName="CurrentGrid" CommandArgument="ReportData" />




<div class="gridWrapper">


<telerik:RadGrid ID="grdReportData" runat="server" PageSize="20" AllowSorting="True"


AllowPaging="True" AutoGenerateColumns="True" ShowGroupPanel="True" CssClass="grid"


ClientSettings-Resizing-AllowColumnResize="true" ClientSettings-Resizing-ResizeGridOnColumnResize="true"




<PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>


<GroupPanel Text="">




<MasterTableView Width="100%" TableLayout="Fixed">



No records exist for the given criteria.






<ClientSettings AllowGroupExpandCollapse="True" AllowDragToGroup="True">


<Resizing AllowColumnResize="True" ResizeGridOnColumnResize="True"></Resizing>












<asp:PostBackTrigger ControlID="imgToExcel" />









Code.ASPX.vb File

Public sub LoadReport()
Dim Ds as dataset = nothing
Ds = Obj.GetDate()

grdReportData.DataSource = ds

End Sub



Thank You In Advance,

1 Answer, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 14 Sep 2012, 07:19 PM
I found the solution with the below code. Just take a look at this please.

Sub grdReportData_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles grdReportData.ColumnCreated

gbc.HeaderText = dtNow.ToString(

"dddd", CultureInfo.CreateSpecificCulture("en-US")) + "-" + dtNow.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture)

gbc.HeaderStyle.Width = Unit.Pixel(73)


Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Share this question