My webgrid clears when paging. I have read other forum comments regardnig paging issues and tried to implement them without success.
My web page has three objects, dropdownlist, and two calendar controls. the user must select from the first two in order to populate the grid. The second, ending date, defaults to the current date on Page Load. If the user choose to changed the ending date they can.
When I select for instance, page 2, the grid clears. But when I change the beginning date, the records the ought to show for the page is populated to the grid for the correct page. It appears that the data is in memory for each page in paging, but it is not writing to the grid.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
btnExportGrid.Visible = False
rdoBtnListExportOptions.Visible = False
lblEndDate.Text = Calendar2.SelectedDate
lblBeginDate.Text = Calendar1.SelectedDate
ddlLocation.DataBind()
ddlLocation.Items.Insert(0, New ListItem("--Select A Location--", ""))
End Sub
' Enable paging by default
'Me.ugGridExceptions.DisplayLayout.Pager.AllowPaging = True
' Disable paging if there aren't enough rows for more than one page
If (Me.ugGridExceptions.DisplayLayout.Pager.PageCount < 2) Then
Me.ugGridExceptions.DisplayLayout.Pager.AllowPaging = False
End If
ugGridExceptions.DisplayLayout.Pager.PageSize = RecordsPerPage
Me.ugGridExceptions.DisplayLayout.Pager.AllowPaging = True
Me.ugGridExceptions.DisplayLayout.EnableInternalRowsManagement = True
' Set the grid's current page appropriately
ugGridExceptions.DisplayLayout.Pager.CurrentPageIndex = e.NewPageIndex
' Rebind the grid to account for the new page
Me.ugGridExceptions.DisplayLayout.NoDataMessage = "No employee records match your search criteria" 'message no showing up in the grid
.Columns.Clear() 'without columns.clear the first column is column 0 in the grid.
' UserID
.Width = 50
.Hidden = False
.Header.Caption = "LocationID"
.IsBound = True
.BaseColumnName = "LocationID"
.Key = "LocationID"
.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.RowTemplateOnly
End With
' Employee
.Width = 150
.Header.Caption = "Employee"
.BaseColumnName = "Employee"
.Key = "Employee"
'more columns follow, but did not include
I got the answer:
BindugGridExceptions()
AND
REMOVE
Protected Sub ugGridExceptions_InitializeDataSource