RadList ItemTemplate unable to get at the Eval values.

5 posts, 0 answers
  1. Mick
    Mick avatar
    40 posts
    Member since:
    Oct 2006

    Posted 04 Aug 2011 Link to this post

    I am unable to retrieve the values for list box items when I am using the template column when in a different event such as a button click.
    I need to get at the values for the selected item.

    my ascx does this
                        <telerik:RadListBox ID="UserLst" runat="server" Width="320px" Height="400px" AutoPostBack="True"
                            Skin="Windows7">
                            <ItemTemplate>
                                <div class="radlist-itemdiv">
                                    <div class="radlist-imagediv">
                                        <img src='Images/icon_human.png' alt="User Image" />
                                    </div>
                                    <div class="radlist-textdiv">
                                        <span class="radlist-title"><span class="radlist-column">Access Rights</span><%#Eval("AccessLevel")%></span><br /><span class="radlist-title"><span class="radlist-column">Full Name</span><%#Eval("Fullname")%></span><br /><span class="radlist-title"><span class="radlist-column">User Ref No.</span><%#Eval("UIDRef")%></span></div>
                                </div>
                            </ItemTemplate>
                        </telerik:RadListBox>

    in my .CS Code file I am doing this in page_load          
    UserLst.DataSource = WS.GetUserList(); // returns a dataset
    UserLst.DataBind();

    in my .cs file I have wired an imagebuttonclick event using radajaxpanel.

            protected void EditUserClick(object sender, ImageClickEventArgs e)
            {
                string UIDRef = xxx;  // get the UIDRef that is in the selecteditem        ????????    
            }

    This last buttonclick routine is where I am strugling to get at the UIDRef that is part of the selected item?
    Once I have the UIDRef i can locate the full record and start to edit it.

    Any help greatly appreciated, Thanks.

  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 09 Aug 2011 Link to this post

    Hi Mick,

    My suggestion is to bind the "UIDRef" to the value field of the RadListBox's items and then you could easily access it in code behind using the Value property of the selected item of the RadListBox.

    All the best,
    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mick
    Mick avatar
    40 posts
    Member since:
    Oct 2006

    Posted 09 Aug 2011 Link to this post

    Hi

    I like your thinking here,
    As yet I am not sure how to automatically bind to the list items value using the UserLst.DataSource = WS.GetUserList(); method which simply returns a dataset but at the worst I can of course re-iterate through the newly created radlist items after calling databind() and add the values in using the datset returned from the WCF as the they will be in the same order.

    Thanks for your pointer Dimitar.
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 12 Aug 2011 Link to this post

    Hi Mick,

    Please refer to the following demo showing how to bind data to the Value filed of the RadListBox's items. In case this is not suitable for your scenario you could subscribe on the server-side onitemdatabound event which is fired for every item and use the following implementation of the event handler function:
    protected void RadListBox_ItemDataBound(object sender, RadListBoxItemEventArgs e)
       {
          DataRowView dataItem = e.Item.DataItem as DataRowView;
     
          e.Item.Value = dataItem["UIDRef"].ToString();
     
       }

    Regards,
    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Mick
    Mick avatar
    40 posts
    Member since:
    Oct 2006

    Posted 12 Aug 2011 Link to this post

    Thanks Dimitar thats great,

    it worked a treat.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017