This is a migrated thread and some comments may be shown as answers.

Getting attribute or GetDataKeyValue Problem OnNeedDataSource for a Listview inside other listview

1 Answer 79 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Cuneyt
Top achievements
Rank 1
Cuneyt asked on 18 Feb 2014, 09:03 PM
 I am trying to add a listview inside another listview itemtemplate. parent listview has openaccesslinqdatasource. inner listview has onneeddatasource. But i cant access any control custom attribute or parent GetDataKeyValue . There is old post here about it but no result avery time give me null. Thank you.
 basic structure.

***************---------------***************
<telerik:RadAjaxPanel ID="apCevapList" runat="server"
                                     ViewStateMode="Enabled"
                                     EnableViewState="true">

          <telerik:RadListView ID="lvParent" runat="server"
                                      DataKeyNames="CId"
                                      DataSourceID="OADLSParent"
                                      ViewStateMode="Enabled"
                                      EnableViewState="true"
                                      Skin="MetroTouch">
                                            <ItemTemplate>
                                                          <asp:HiddenField ID="hfCid2" runat="server" Value='<%# Eval("CId") %>' />
                                                          
                                                           <telerik:RadAjaxPanel ID="apCevapYorum" runat="server"
                                                                                ViewStateMode="Enabled" EnableViewState="true">
                                                    
                                                                        <telerik:RadListView ID="lvChild" runat="server"
                                                                                          DataKeyNames="Id"
                                                                                          EnableViewState="true"
                                                                                          ViewStateMode="Enabled"
                                                                                          InsertItemPosition="FirstItem"
                                                                                          AllowPaging="True"
                                                                                          PageSize="5"
                                                                                          Skin="Transparent"
                                                                                          OnNeedDataSource="lvChild_NeedDataSource"
                                                                                           OnItemCommand="lvChild_ItemCommand">
                                                                                         <ValidationSettings CommandsToValidate="PerformInsert"
                                                                                         ValidationGroup="insertGroup"
                                                                                         EnableValidation="true"></ValidationSettings>
                                                                       </telerik:RadListView>
                                                              </telerik:RadAjaxPanel>
                                                  </ItemTemplate>
                                 </telerik:RadListView>

</telerik:RadAjaxPanel>
***************---------------***************

Code behind something like that:

***************---------------***************
protected void lvChild_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
{
RadListView lvChild = (RadListView)sender;
RadListViewDataItem parentItem = (RadListViewDataItem)lvChild.NamingContainer;

var parentDatakeyId = (int)parentItem.GetDataKeyValue("CId"); //This give me null exception
//OR
// this button is in itemtemplate of parent with custom attribute cId= '<%# Eval("CId") %>'
RadButton rb = (RadButton)parentItem.FindControl("btnShowChildLvInsertItem");
 int cId = Convert.ToInt32(rb.Attributes["cId"]);//null
//OR
 HiddenField hf = (HiddenField)parentItem.FindControl("hfCId");
string cId2 = hf.Value;//null
***************---------------***************

i can Access all cid value or other values in itemcommand event of child lv. but there is a problem  at needdatasource event of child listview. all cid null.
Thank you.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Feb 2014, 09:46 AM
Hello Cuneyt,

Posting multiple threads about the same question will make tracking the history of the ticket more complicated.
Please stick to the other thread: http://www.telerik.com/forums/getting-attribute-or-getdatakeyvalue-problem-onneeddatasource-for-a-listview-inside-other-listview-e8409596cc94
Thanks for your understanding.

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ListView
Asked by
Cuneyt
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or