Hi I am using the following code to display self referencing heirarchy and it is working fantastic. My problem is when I enable paging and go to the second page or any other page then I cannnot get the datakeyvalue for the row and it crashes.
This is the markup I am using :
and the code behind is :
This is the error that get when I go to page 2 or any other page except page 1
any help would be most appreciated.
many thanks
This is the markup I am using :
<
telerik:RadTreeList
runat
=
"server"
ID
=
"tvwApp"
AllowPaging
=
"true"
DataKeyNames
=
"AppID"
OnItemCommand
=
"RadTreeList1_ItemCommand"
AutoGenerateColumns
=
"false"
OnPageSizeChanged
=
"RadTreeList1_PageSizeChanged"
OnPageIndexChanged
=
"RadTreeList1_PageIndexChanged"
ParentDataKeyNames
=
"HistoricalappID"
Skin
=
"Windows7"
EnableEmbeddedSkins
=
"true"
ItemStyle-Height
=
"30px"
AlternatingItemStyle-Height
=
"30px"
AllowSorting
=
"true"
HeaderStyle-Height
=
"30px"
AlternatingItemStyle-BackColor
=
"WhiteSmoke"
GridLines
=
"Horizontal"
>
<
AlternatingItemStyle
BackColor
=
"WhiteSmoke"
Height
=
"30px"
></
AlternatingItemStyle
>
<
ItemStyle
Height
=
"30px"
></
ItemStyle
>
<
Columns
>
<
telerik:TreeListBoundColumn
HeaderText
=
"Reference No"
DataField
=
"AppRefNo"
>
<
HeaderStyle
Width
=
"100px"
></
HeaderStyle
>
</
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
HeaderText
=
"Applicant"
DataField
=
"LOTRPNo"
HeaderStyle-Width
=
"35%"
>
</
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
HeaderText
=
"UDA"
DataField
=
"ULDA"
>
</
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
SortExpression
=
"DatePropMade"
HeaderText
=
"Date Properly Made"
DataField
=
"DatePropMade"
DataFormatString
=
"{0:d}"
>
</
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
SortExpression
=
"DateDecision"
HeaderText
=
"Decisione Due"
DataField
=
"DateDecision"
DataFormatString
=
"{0:d}"
>
</
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
SortExpression
=
"StatusName"
HeaderText
=
"Status"
DataField
=
"StatusName"
UniqueName
=
"StatusName"
>
</
telerik:TreeListBoundColumn
>
<
telerik:TreeListBoundColumn
SortExpression
=
"IsPNRequired"
HeaderText
=
" "
DataField
=
"IsPNRequired"
UniqueName
=
"IsPNRequired"
HeaderStyle-Width
=
"0px"
ItemStyle-Width
=
"0px"
ItemStyle-Font-Size
=
"1px"
>
<
HeaderStyle
Width
=
"0px"
></
HeaderStyle
>
<
ItemStyle
Font-Size
=
"1px"
Width
=
"0px"
></
ItemStyle
>
</
telerik:TreeListBoundColumn
>
<
telerik:TreeListTemplateColumn
HeaderStyle-Width
=
"60px"
HeaderText
=
"Edit"
>
<
ItemTemplate
>
<
telerik:RadButton
ID
=
"SelectButton"
runat
=
"server"
CommandName
=
"Edit"
Text
=
"Edit"
ItemStyle-CssClass
=
"edit"
Width
=
"50px"
/>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"60px"
></
HeaderStyle
>
</
telerik:TreeListTemplateColumn
>
<
telerik:TreeListTemplateColumn
HeaderStyle-Width
=
"60px"
HeaderText
=
"Copy"
>
<
ItemTemplate
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
CommandName
=
"Copy"
Text
=
"Copy"
ItemStyle-CssClass
=
"copy"
Width
=
"50px"
/>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"60px"
></
HeaderStyle
>
</
telerik:TreeListTemplateColumn
>
</
Columns
>
<
HeaderStyle
Height
=
"30px"
></
HeaderStyle
>
</
telerik:RadTreeList
>
and the code behind is :
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Handles
Me
.Load
If
Not
IsPostBack
Then
tvwApp.DataSource = LoadData(txtSearch.Text)
tvwApp.DataBind()
tvwApp.ExpandToLevel(1)
txtSearch.Focus()
CreateMenu()
btnAddNew.Text =
"Add New Application"
DisplayAppDetailsHeader()
End
If
End
Sub
Public
Sub
RadTreeList1_ItemCommand(
ByVal
sender
As
Object
,
ByVal
e
As
TreeListCommandEventArgs)
Handles
tvwApp.ItemCommand
If
e.CommandName = RadTreeList.ExpandCollapseCommandName
Then
tvwApp.DataSource = LoadData(txtSearch.Text)
tvwApp.DataBind()
End
If
If
(e.Item.ItemType = TreeListItemType.Item
Or
e.Item.ItemType = TreeListItemType.AlternatingItem)
Then
Dim
item
As
TreeListDataItem =
DirectCast
(e.Item, TreeListDataItem)
Dim
APPID
As
String
= item.OwnerTreeList.DataKeyValues(item.DataItemIndex)(
"AppID"
).ToString()
If
e.CommandName =
"Copy"
Then
Response.Redirect(_apppath +
"copy.aspx?ID="
& APPID &
"&tabId=tab1&Action=PREAPP"
)
ElseIf
e.CommandName =
"Edit"
Then
Response.Redirect(_apppath +
"process.aspx?ID="
& APPID &
"&tabId=tab1&Action=PREAPP"
)
End
If
End
If
End
Sub
Protected
Sub
RadTreeList1_PageIndexChanged(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.TreeListPageChangedEventArgs)
tvwApp.CurrentPageIndex = e.NewPageIndex
tvwApp.DataSource = LoadData(txtSearch.Text)
tvwApp.DataBind()
End
Sub
Protected
Sub
RadTreeList1_PageSizeChanged(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.TreeListPageSizeChangedEventArgs)
tvwApp.DataSource = LoadData(txtSearch.Text)
tvwApp.DataBind()
End
Sub
This is the error that get when I go to page 2 or any other page except page 1
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
'error occurs on this line
Dim
APPID
As
String
= item.OwnerTreeList.DataKeyValues(item.DataItemIndex)(
"AppID"
).ToString()
any help would be most appreciated.
many thanks