Get ListBoxItem data value from code behind

2 posts, 0 answers
  1. Max
    Max avatar
    3 posts
    Member since:
    May 2015

    Posted 30 Mar Link to this post

     

    Hi - I need to get the data value of the item that has been transferred using code behind. Please could you give me an example. Thank you.

      

    Protected Sub RadListBox2_Inserted(ByVal sender As Object, ByVal e As RadListBoxEventArgs)
           .....code to get the data value of the item that was transferred......
     
      End Sub

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 04 Apr Link to this post

    Hello Max,

    In order to get the data from the item/items transferred in the code-behind, you have to set the source ListBox' AutoPostBackOnTransfer property to true and in the control's OnTransferred server-side event handler you can access the collection (e.Items) of transferred items and each item in it by index:
    Protected Sub RadListBox1_Transferred(sender As Object, e As Telerik.Web.UI.RadListBoxTransferredEventArgs)
        Label1.Text += "Items with Text/Value transferred: "
        For i As Integer = 0 To e.Items.Count - 1
            Label1.Text += "[" + e.Items(i).Text + "/" + e.Items(i).Value + "]"
        Next
    End Sub

    The code snippet above gets the transferred items' Text and Value property values and updates a Label's Text with the data.

    Regards,
    Ivan Danchev
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top