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
815
Custom Pager Not Paging Correctly
posted

I have a WebDataGrid using a custom pager that I built in an ASCX file (attached to this post). The SelectCommand for my SqlDataSource is being built in the code behind and bound to the grid on Button.Click based on several conditions that the user specifies. My pager is not properly changing pages when the buttons are clicked. Can anyone please point me in the right direction regarding what might be causing this problem?

Here is my grid:

<ig:WebDataGrid ID="WDGWells" OnDataFiltered="WDGWells_DataFiltered" OnCustomDataBinding="WDGWells_CustomDataBinding" runat="server" Height="550px" Width="99.8%" AutoGenerateColumns="False" DataSourceID="SDSWells" >

<Columns>

<ig:BoundDataField DataFieldName="ID" Key="ID" Hidden="true">

<Header Text="ID" />

</ig:BoundDataField>

<ig:TemplateDataField Key="Options" Width="120px" Hidden="false">

<Header Text="Options" />

<ItemTemplate>

<asp:ImageButton runat="server" ID="iBTNShowLogs" CommandArgument='<%#Eval("ID")%>' Visible="true" CommandName="ShowLogs" ImageUrl="~/icons/binoculars_24.png" ToolTip="View Logs for this well" />

<asp:ImageButton ID="iBTNAdd2APIPickList" runat="server" ImageUrl="~/icons/notes_24.png" CommandArgument='<%# Eval("ID")%>' CommandName="Add2PickAPIList" ToolTip="Add to API Pick List" />

<a href='<%#"http://rrcsearch.neubus.com/esd-rrc/api.php?function=GetWellLogs&api_no=" & Eval("APINumber").ToString.Substring(2, Eval("APINumber").ToString.Length - 2)%>' id="HLKTXComp" target="_blank"><img alt="" src="../icons/tx.png" /></a>

<a href='<%#"http://gis2.rrc.state.tx.us/cgi-bin/vwf.cgi?apinum=" & Eval("APINumber").ToString.Substring(2, Eval("APINumber").ToString.Length - 2)%>' id="HLKTXLogs" target="_blank"><img alt="" src="../icons/tx.png" /></a>

</ItemTemplate>

</ig:TemplateDataField>

<ig:BoundDataField DataFieldName="LogKey" Key="LogKey" Width="35px" Header-Tooltip="Click to Sort by PDL #">

<Header Text="PDL #" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="Name" Key="Name" Width="165px" Header-Tooltip="Click to Sort by Well Name">

<Header Text="Well Name" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="Number" Key="Number" Width="25px" Header-Tooltip="Click to Sort by Number">

<Header Text="Num" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="County" Key="County" Header-Tooltip="Click to sort by County" >

<Header Text="County" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="API" Key="API" Width="80px" Header-Tooltip="Click to Sort by API">

<Header Text="API" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="Depth" Key="Depth" Width="40px" Header-Tooltip="Click to Sort by Depth">

<Header Text="Depth" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="AbstractNumber" Key="AbstractNumber" Width="50px" Hidden="false" Header-Tooltip="Click to Sort by Abstract Number">

<Header Text="Abstract" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="FieldName" Key="FieldName" Header-Tooltip="Click to Sort by Field Name">

<Header Text="Field" />

</ig:BoundDataField>

<ig:BoundDataField DataFieldName="Operator" Key="Operator" Hidden="false" Header-Tooltip="Click to Sort by Operator">

<Header Text="Operator" />

</ig:BoundDataField>

</Columns>

<Behaviors>

<ig:Filtering></ig:Filtering>

<ig:Sorting></ig:Sorting>

<ig:Paging PageSize="15" PagerAppearance="Bottom">

<%--<PagingClientEvents Initialize="WebDataGridView_Initialize" PageIndexChanged="WebDataGridView_PageIndexChanged"

PageIndexChanging="WebDataGridView_PageIndexChanging" />--%>

<PagerTemplate>

<eml:SearchPager id="CustomerPager" runat="server" />

</PagerTemplate>

</ig:Paging>

</Behaviors>

</ig:WebDataGrid>



Here is the code that loads my pager's DropDownList (the available pages in the grid) when they click the "Search" button:

' get a reference to the drop down list within the pager

Dim DDLPager As DropDownList = DirectCast(DirectCast(WDGWells.Behaviors.Paging.PagerTemplateContainerBottom.FindControl("CustomerPager"), SearchPager).FindControl("PagerPageList"), DropDownList)

DDLPager.Items.Clear()

For i As Integer = 1 To Math.Ceiling(WellCount / 15)

    DDLPager.Items.Add(New ListItem(i, i))

Next

' refresh the grid

SDSWells.SelectCommand = sqlCommandString

SDSWells.DataBind()

WDGWells.Rows.Clear()

WDGWells.DataBind()

WDGWells.Behaviors.Filtering.ApplyFilter()

' add the PageChanged event handler to the custom pager

Dim pagerControl As SearchPager = DirectCast(WDGWells.Behaviors.Paging.PagerTemplateContainerBottom.FindControl("CustomerPager"), SearchPager)

AddHandler pagerControl.PageChanged, AddressOf currentPageControl_PageChanged

pagerControl.DataBind()

pagerControl.SetCurrentPageNumber(DDLPager.SelectedValue)



Here are my WebDataGrid events:

Protected Sub WDGWells_DataFiltered(sender As Object, e As Infragistics.Web.UI.GridControls.FilteredEventArgs) Handles WDGWells.DataFiltered

Dim DDLPager As DropDownList = DirectCast(DirectCast(WDGWells.Behaviors.Paging.PagerTemplateContainerBottom.FindControl("CustomerPager"), SearchPager).FindControl("PagerPageList"), DropDownList)

Dim OfLabel As System.Web.UI.WebControls.Label = DirectCast(DirectCast(WDGWells.Behaviors.Paging.PagerTemplateContainerBottom.FindControl("CustomerPager"), SearchPager).FindControl("LBLOf"), System.Web.UI.WebControls.Label)

OfLabel.Text = "Of " & Math.Ceiling(WellCount / 15)

DDLPager.Items.Clear()

For i As Integer = 1 To (WellCount / 15)

DDLPager.Items.Add(New ListItem(i, i))

Next

End Sub



Protected Sub WDGWells_CustomDataBinding(sender As Object, e As DataBindingEventArgs)

Dim currentPage As Integer = grid.Behaviors.Paging.PageIndex

Dim pageSize As Integer = grid.Behaviors.Paging.PageSize

Dim startIndex As Integer = currentPage * pageSize

' I OMITTED THE LONG CODE HERE THAT BUILDS THE SelectCommand FOR MY SqlDataSource

SDSWells.SelectCommand = sqlCommandString

SDSWells.DataBind()

WDGWells.Rows.Clear()

WDGWells.DataBind()

WDGWells.Behaviors.Filtering.ApplyFilter()

CustomPager.zip
Parents Reply Children
No Data