I have a dropdown list in a pager template. I am attempting to set the page index of a listview using the dropdownlist in the datapager to allow the customer to jump to a record using more meaningful text than a page number. The page size will always be 1.
MARKUP
VB
The text value of the dropdown list is similar to "XXB123" and "IMO45687" and isn't always sequential. That is why I want to use the selected index.
MARKUP
<
telerik:RadListView
ID
=
"RadListView1"
runat
=
"server"
AllowPaging
=
"True"
DataSourceID
=
"sqlActPlus"
ItemPlaceholderID
=
"ActionContainer"
PageSize
=
"1"
>
<
LayoutTemplate
>
<
asp:PlaceHolder
ID
=
"ActionContainer"
runat
=
"server"
/>
<
telerik:RadDataPager
ID
=
"RadDataPager1"
runat
=
"server"
PagedControlID
=
"RadListView1"
PageSize
=
"1"
>
<
Fields
>
<
telerik:RadDataPagerButtonField
FieldType
=
"FirstPrev"
/>
<
telerik:RadDataPagerButtonField
FieldType
=
"Numeric"
/>
<
telerik:RadDataPagerButtonField
FieldType
=
"NextLast"
/>
<
telerik:RadDataPagerTemplatePageField
>
<
PagerTemplate
>
<
asp:DropDownList
ID
=
"drpActionList"
DataSourceID
=
"sqlActPlus"
DataTextField
=
"Action"
DataValueField
=
"Action"
runat
=
"server"
AutoPostBack
=
"true"
OnSelectedIndexChanged
=
"drpActionList_SelectedIndexChanged"
>
</
asp:DropDownList
>
</
PagerTemplate
>
</
telerik:RadDataPagerTemplatePageField
>
<
telerik:RadDataPagerTemplatePageField
>
<
PagerTemplate
>
<
div
style
=
"float: right"
>
<
b
>Action
<
asp:Label
runat
=
"server"
ID
=
"CurrentPageLabel"
Text="<%# Container.Owner.StartRowIndex+1%>" />
to
<
asp:Label
runat
=
"server"
ID
=
"TotalPagesLabel"
Text="<%# IIF(Container.Owner.TotalRowCount > (Container.Owner.StartRowIndex+Container.Owner.PageSize), Container.Owner.StartRowIndex+Container.Owner.PageSize, Container.Owner.TotalRowCount) %>" />
of
<
asp:Label
runat
=
"server"
ID
=
"TotalItemsLabel"
Text="<%# Container.Owner.TotalRowCount%>" />
<
br
/>
</
b
>
</
div
>
</
PagerTemplate
>
</
telerik:RadDataPagerTemplatePageField
>
</
Fields
>
</
telerik:RadDataPager
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
fieldset
>
<
legend
>Action</
legend
>
<
table
class
=
"FullWidthTable"
>
<
tbody
>
<
tr
>
<
th
>
Action Number
</
th
>
<
th
>
Target Date
</
th
>
<
th
>
Type
</
th
>
</
tr
>
<
tr
>
<
td
class
=
"ReadOnlyValue"
>
<%# Eval("ActionNo")%>
</
td
>
<
td
class
=
"ReadOnlyValue"
>
<%# Eval("TargetMast", "{0:d}")%>
</
td
>
<
td
class
=
"ReadOnlyValue"
>
<%# Eval("Type")%>
</
td
>
</
tr
>
</
tbody
>
</
table
>
</
fieldset
>
</
ItemTemplate
>
</
telerik:RadListView
>
VB
Protected
Sub
drpActionList_SelectedIndexChanged(
ByVal
sender
As
DropDownList,
ByVal
e
As
System.EventArgs)
Dim
dataPager
As
Telerik.Web.UI.RadDataPager =
DirectCast
(RadListView1.FindControl(
"RadDataPager1"
), Telerik.Web.UI.RadDataPager)
If
dataPager IsNot
Nothing
Then
dataPager.PageIndex = sender.SelectedIndex
' I realize this line doesn't work
End
If
End
Sub
The text value of the dropdown list is similar to "XXB123" and "IMO45687" and isn't always sequential. That is why I want to use the selected index.