Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
290
Grid Clears when paging
posted

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.

Code

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim bBeginDate As String = lblBeginDate.Text Dim eEndDate As String = lblEndDate.Text

If Not Page.IsPostBack Then

Me.BindData()

btnExportGrid.Visible = False

rdoBtnListExportOptions.Visible = False

Calendar1.SelectedDate = Date.NowCalendar2.SelectedDate = Date.Now

lblEndDate.Text = Calendar2.SelectedDate

lblBeginDate.Text = Calendar1.SelectedDate

ddlLocation.DataBind()

ddlLocation.Items.Insert(0, New ListItem("--Select A Location--", ""))

End If

End Sub

Private Sub BindData()

' Enable paging by default

'Me.ugGridExceptions.DisplayLayout.Pager.AllowPaging = True

Me.ugGridExceptions.DataSource = Me.dsAttendance.Tables("usp_ExcelReport").DefaultView Me.ugGridExceptions.DataBind()

' 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

End Sub

Protected Sub ugGridExceptions_InitializeDataSource(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs) Handles ugGridExceptions.InitializeDataSource

ugGridExceptions.DisplayLayout.Pager.PageSize = RecordsPerPage

ugGridExceptions.DataSource =
Me.dsAttendance.Tables("usp_Report").DefaultView Me.ugGridExceptions.DataBind()

Me.ugGridExceptions.DisplayLayout.Pager.AllowPaging = True

Me.ugGridExceptions.DisplayLayout.Pager.PageSize = RecordsPerPage Me.ugGridExceptions.DisplayLayout.RowsRange = 100

Me.ugGridExceptions.DisplayLayout.EnableInternalRowsManagement = True

End Sub

Private Sub UltraWebGrid1_PageIndexChanged(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.PageEventArgs) Handles ugGridExceptions.PageIndexChanged

' Set the grid's current page appropriately

ugGridExceptions.DisplayLayout.Pager.CurrentPageIndex = e.NewPageIndex

' Rebind the grid to account for the new page

Me.BindData()

End Sub

Protected Sub UltraWebGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles ugGridExceptions.InitializeLayout With Me.ugGridExceptions

Me.ugGridExceptions.DisplayLayout.Pager.AllowPaging = True

Me.ugGridExceptions.DisplayLayout.NoDataMessage = "No employee records match your search criteria" 'message no showing up in the grid

Me.ugGridExceptions.DisplayLayout.Pager.PageSize = RecordsPerPage

.Columns.Clear() 'without columns.clear the first column is column 0 in the grid.

' UserID

.Columns.Add(New Infragistics.WebUI.UltraWebGrid.UltraGridColumn)With .Columns(.Columns.Count - 1)

.Width = 50

.Hidden = False

.Header.Caption = "LocationID"

.IsBound = True

.BaseColumnName = "LocationID"

.Key = "LocationID"

.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.RowTemplateOnly

End With

' Employee

.Columns.Add(New Infragistics.WebUI.UltraWebGrid.UltraGridColumn)With .Columns(.Columns.Count - 1)

.Width = 150

.Hidden = False

.Header.Caption = "Employee"

.IsBound = True

.BaseColumnName = "Employee"

.Key = "Employee"

.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.RowTemplateOnly

End With

'more columns follow, but did not include

End With

End Sub

Parents
No Data
Reply
  • 290
    Verified Answer
    posted

     

    I got the answer:

    Protected Sub ugGridExceptions_PageIndexChanged(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.PageEventArgs) Handles ugGridExceptions.PageIndexChanged

    ugGridExceptions.DisplayLayout.Pager.CurrentPageIndex = e.NewPageIndex

    BindugGridExceptions()

    End Sub

    AND

    REMOVE

    Protected Sub ugGridExceptions_InitializeDataSource

    End Sub

Children
No Data