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

2 posts, 0 answers
  1. Cuneyt
    Cuneyt avatar
    36 posts
    Member since:
    Dec 2011

    Posted 18 Feb 2014 Link to this post

     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.
  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 24 Feb 2014 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top