Protected Overrides Sub CreateChildControls()
Try
MyBase.CreateChildControls()
Dim imgClear As New Image
Dim pbTrigger As New PostBackTrigger
pbTrigger.ControlID = btnDownload1.ID
'Set up the form for date parameters
pnlDates.ID =
"pnlDate" + Me.ID
lblBeginDate.CssClass =
"form"
lblEndDate.CssClass =
"form"
'Populate the date fields with the default values
txtBeginDate.CssClass =
"content"
txtEndDate.CssClass =
"content"
btnDownload1.ImageUrl =
"/Style Library/images/download1.gif"
btnRetrieve.ImageUrl =
"/Style Library/en-us/custom/retrieve.gif"
imgClear.ImageUrl =
"/Style Library/en-us/custom/clear.gif"
pnlDates.Controls.Add(lblBeginDate)
pnlDates.Controls.Add(txtBeginDate)
pnlDates.Controls.Add(lblEndDate)
pnlDates.Controls.Add(txtEndDate)
pnlDates.Controls.Add(
New LiteralControl("<div class=""subButton""><a href=""javascript:document.forms[0].reset()"">"))
pnlDates.Controls.Add(imgClear)
pnlDates.Controls.Add(
New LiteralControl("</a>"))
pnlDates.Controls.Add(btnDownload1)
pnlDates.Controls.Add(btnRetrieve)
pnlDates.Controls.Add(
New LiteralControl("</div><br /><br />"))
Me.Controls.Add(pnlDates)
'Set up the radgrid properties
oGrid.ID =
"oGrid"
oGrid.EnableEmbeddedSkins =
False
oGrid.Skin =
"NNG"
oGrid.Attributes.Add(
"runat", "server")
oGrid.AutoGenerateColumns =
True
oGrid.ShowHeader =
True
oGrid.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric
oGrid.PagerStyle.Position = GridPagerPosition.Bottom
' Display the download button if enabled
btnDownload2.ImageUrl =
"/Style Library/images/download2.gif"
pnlExport.ID =
"pnlExport" + Me.ID
pnlExport.Controls.Add(
New LiteralControl("<div class=""subButton"">"))
pnlExport.Controls.Add(btnDownload2)
pnlExport.Controls.Add(
New LiteralControl("</div><br /><br />"))
Me.Controls.Add(pnlExport)
Me.Controls.Add(oGrid)
Catch ex As Exception
Dim ctx As HttpContext = HttpContext.Current
childException = ex
End Try
End Sub
Protected Sub btnDownload_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnDownload1.Click, btnDownload2.Click
oGrid.ExportSettings.ExportOnlyData =
False
oGrid.ExportSettings.IgnorePaging =
True
oGrid.ExportSettings.OpenInNewWindow =
True
If fileName.Length > 0 Then
oGrid.ExportSettings.FileName = fileName
End If
oGrid.MasterTableView.ExportToCSV()
End Sub
Private Sub CustomReportingWebPart_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Try
'We need to see if we should display the date forms fields
pnlDates.Visible = useDateParams
'If the date parameters are not visible, then we need to display the export panel, otherwise
' the export button is displayed with the clear and retreive buttons
If useDateParams Then
Me.pnlExport.Visible = False
Else
Me.pnlExport.Visible = True
End If
oGrid.AllowPaging = enablePaging
oGrid.AllowFilteringByColumn = enableFiltering
oGrid.AllowSorting = enableSorting
oGrid.ClientSettings.Scrolling.AllowScroll = enableScrolling
oGrid.ClientSettings.Scrolling.UseStaticHeaders = enableStaticHeaders
oGrid.PageSize = pageSize
oGrid.Width = Unit.Percentage(100)
'Populate the date fields with correct values
lblBeginDate.Text = beginDateLabel +
"<br>"
lblEndDate.Text =
"<br>" + endDateLabel + "<br>"
txtBeginDate.Text = dBeginDate.ToString(
"MM/dd/yyyy")
txtEndDate.Text = dEndDate.ToString(
"MM/dd/yyyy")
'Bind the datasource to get the latest changes
oGrid.DataSource = getDatavalues()
oGrid.DataBind()
Catch ex As Exception
Dim ctx As HttpContext = HttpContext.Current
childException = ex
End Try
End Sub
Any ideas on how to resolve this issue?
Thanks!