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
Grid
This is a migrated thread and some comments may be shown as answers.
Satish
Top achievements
Rank 1
Satish asked on 14 Sep 2012, 02:37 PM
Hello, 

        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:

Code.ASPX:

<

 

 

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

 

<fieldset>

 

<legend>Result</legend>

 

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

 

<ContentTemplate>

 

<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>

 

<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"

 

ShowFooter="true">

 

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

 

<GroupPanel Text="">

 

</GroupPanel>

 

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

 

<NoRecordsTemplate>

No records exist for the given criteria.

 

</NoRecordsTemplate>

 

</MasterTableView>

 

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

 

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

 

</ClientSettings>

 

</telerik:RadGrid>

 

</div>

 

</ContentTemplate>

 

<Triggers>

 

<asp:PostBackTrigger ControlID="imgToExcel" />

 

</Triggers>

 

</asp:UpdatePanel>

 

</fieldset>

 

</div>


Code.ASPX.vb File

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

grdReportData.DataSource = ds

grdReportData.DataBind()
End Sub

 

 

Thank You In Advance,
Satish.

1 Answer, 1 is accepted

Sort by
0
Satish
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)


End
Sub


Tags
Grid
Asked by
Satish
Top achievements
Rank 1
Answers by
Satish
Top achievements
Rank 1
Share this question
or