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

how to retrieve values to my rad text box, using SQLDataSource

3 Answers 64 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Hamza
Top achievements
Rank 1
Hamza asked on 20 Sep 2011, 03:37 PM
Hi all :)

I have a SQLData source, connected to radlistbox

I want to retrieve some data when I choose an item

suppose here is my table

Vedios:
- Video ID
- Video Name
- Video Path

I want to ( for example ) to retrieve the name and the path when I choose an Item inside my listbox and set it as a text in atextbox

how can I do that ?


thank you all :)

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Sep 2011, 12:48 PM
Hello Hamza,

You can hook RadListBox1_SelectedIndexChanged and access the selected Item
C#:
protected void RadListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox1.Text = RadListBox1.SelectedItem.Text;
    }

Thanks,
Shinu.
0
Rohit
Top achievements
Rank 1
answered on 23 Sep 2011, 04:09 PM
In continuation to the above question:

How would I retrieve the VideoID?
(Assuming I am not displaying the VideoID.. I am just displaying the Video Name & Path)

Thanks !!
0
Peter Filipov
Telerik team
answered on 28 Sep 2011, 02:10 PM
Hello Rohit,

RadListBox control can be bind as follow:
RadListBox1.DataTextField = "VideoID";
RadListBox1.DataValueField = "VideoName";
RadListBox1.DataKeyField = "VideoPath";


All the values can be retrieved on server side as properties of the RadListBoxItem.

Kind regards,
Peter Filipov
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ListBox
Asked by
Hamza
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rohit
Top achievements
Rank 1
Peter Filipov
Telerik team
Share this question
or