Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnbackupsheet.Click Dim totalcount = CheckBoxList1.Items.Cast(Of ListItem)().Where(Function(item) item.Selected).Count() Dim NumberOfGrids As Integer = totalcount For i As Integer = 0 To NumberOfGrids - 1 Dim ds As New DataSet ds = Session("query31ds") Dim dt1 As New DataTable dt1 = ds.Tables(0) Dim gv As New GridView() gv.AutoGenerateColumns = False Dim bf As New BoundField bf.HeaderText = "Name" bf.DataField = "Name" gv.Columns.Add(bf) Dim createStartDate As New Date(Now.Year, Now.Month, 1) Dim count = dt1.Columns.Count For j = 1 To count - 1 ' Here is template column portion Dim TmpCol As New TemplateField() Dim date1 As Date date1 = createStartDate.AddDays(j - 1).ToShortDateString() TmpCol.HeaderText = date1.ToString("dd-MMM") TmpCol.ItemTemplate = New TemplateHandler() gv.Columns.Add(TmpCol) Next gv.DataSource = Session("query31ds") gv.DataBind() GridviewsContainer.Controls.Add(gv) Next End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)