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

RadList ItemTemplate unable to get at the Eval values.

4 Answers 90 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Mick
Top achievements
Rank 1
Mick asked on 04 Aug 2011, 05:24 PM
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.

4 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 09 Aug 2011, 11:37 AM
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.

0
Mick
Top achievements
Rank 1
answered on 09 Aug 2011, 06:31 PM
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.
0
Dimitar Terziev
Telerik team
answered on 12 Aug 2011, 11:52 AM
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.

0
Mick
Top achievements
Rank 1
answered on 12 Aug 2011, 03:52 PM
Thanks Dimitar thats great,

it worked a treat.
Tags
ListBox
Asked by
Mick
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Mick
Top achievements
Rank 1
Share this question
or