Hello
I'm building a blog and each post corresponds to an item in the ListView that is bounded to a sql datasource. Each post is identify for a unique record number.
For each item in the listview I need to show other listview inside the item containing the attached files for this particular post. The records for this second listview should be obtained with "OnNeedDataSource" because this list is builded exploring the directory where the attached files are stored.
Is it possible to do that? Anyone has an example? How can I identify the record number of the post in this event routine.
Thanks in advance
I'm building a blog and each post corresponds to an item in the ListView that is bounded to a sql datasource. Each post is identify for a unique record number.
For each item in the listview I need to show other listview inside the item containing the attached files for this particular post. The records for this second listview should be obtained with "OnNeedDataSource" because this list is builded exploring the directory where the attached files are stored.
Is it possible to do that? Anyone has an example? How can I identify the record number of the post in this event routine.
Thanks in advance
4 Answers, 1 is accepted
0
Hello Roberto,
In order to achieve the requested functionality you may use nested ListView's NamingContainer, which in this case should be parent listView's RadListViewDataItem to access the appropriate DataKeyValue. Similar to the following:
and simple lyout:
All the best,
Rosen
the Telerik team
In order to achieve the requested functionality you may use nested ListView's NamingContainer, which in this case should be parent listView's RadListViewDataItem to access the appropriate DataKeyValue. Similar to the following:
protected
void
FilesListView_NeedDataSource(
object
sender, RadListViewNeedDataSourceEventArgs e)
{
var innerListView = ((RadListView)sender);
var parentListViewItem = innerListView.NamingContainer
as
RadListViewDataItem;
var parentPostId = (
int
)parentListViewItem.GetDataKeyValue(
"PostId"
);
innerListView.DataSource = GetFilesByPostId(parentPostId);
}
and simple lyout:
<
telerik:RadListView
runat
=
"server"
ID
=
"PostListView"
DataKeyNames
=
"PostId"
>
<
ItemTemplate
>
<%--....--%>
<
telerik:RadListView
ID
=
"FilesListView"
runat
=
"server"
OnNeedDataSource
=
"FilesListView_NeedDataSource"
>
<
ItemTemplate
>
<%--....--%>
</
ItemTemplate
>
</
telerik:RadListView
>
</
ItemTemplate
>
</
telerik:RadListView
>
All the best,
Rosen
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Blas
Top achievements
Rank 1
answered on 06 Sep 2010, 07:35 AM
Hello Rosen,
Thank you very much for your answer. It works fine!!!
Greetings
Thank you very much for your answer. It works fine!!!
Greetings
0
Carlo
Top achievements
Rank 1
answered on 22 Oct 2010, 05:05 PM
I ran into a similar issue (but with a RadGrid inside the RadListview's itemtemplate instead of another list view), if I try the above code:
This always seems to yield the previous datakey value (i.e. the item displayed last before the current item displayed).
This happens when I click the page buttons on the RadPager of the RadListView.
Example:
Let's say I was viewing the 4th Item with a datakeyvalue of 4, on the initial call to RadGrid_NeedDataSource, the code
above returns 4. If I then click the radlistview page button for the 9th Item with a datakeyvalueof 9, in the second call to RadGrid_NeedDataSource the code above returns 4 again, if I then naviate back to the 4th item in the third call to
RadGrid_NeedDataSource the code above returns 9 etc.
Did I setup something wrong?
-Carlo
var parentPostId = (
int
)parentListViewItem.GetDataKeyValue(
"PostId"
);
This always seems to yield the previous datakey value (i.e. the item displayed last before the current item displayed).
This happens when I click the page buttons on the RadPager of the RadListView.
Example:
Let's say I was viewing the 4th Item with a datakeyvalue of 4, on the initial call to RadGrid_NeedDataSource, the code
above returns 4. If I then click the radlistview page button for the 9th Item with a datakeyvalueof 9, in the second call to RadGrid_NeedDataSource the code above returns 4 again, if I then naviate back to the 4th item in the third call to
RadGrid_NeedDataSource the code above returns 9 etc.
Did I setup something wrong?
-Carlo
0
Hello Carlo,
I have replayed to your post on the following thread:
http://www.telerik.com/community/forums/aspnet-ajax/listview/radgrid-inside-radlistview-problem.aspx
Regards,
Nikolay
the Telerik team
I have replayed to your post on the following thread:
http://www.telerik.com/community/forums/aspnet-ajax/listview/radgrid-inside-radlistview-problem.aspx
Regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items