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

List Box Item Click event?

3 Answers 538 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Saima Gul
Top achievements
Rank 1
Saima Gul asked on 18 Mar 2010, 06:41 AM
Hi
My requirement is to get some values from database and show in a section (which can be hide by user)  when user click on item of list box whether it is already selected or not. List box has selected index change event which occurs when we change selection. So if List box has only one item then it can not fullfill my requirement. i need some item click like event so that functionally must occur whether item is already selected or not

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 22 Mar 2010, 05:16 PM
Hello Saima Gul,

Indeed you are right. RadListBox won't fire its SelectedIndexChanged event on subsequent clicks on the same item. The reason for this is that the selected index is not being changed at all. However, there is a workaround that you can use. I have prepared sample project demonstrating how to execute server click handler on every RadListBoxItem click. You can find the sample as an attachment.

Sincerely yours,
Genady Sergeev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Saima Gul
Top achievements
Rank 1
answered on 27 Mar 2010, 08:36 AM
Thanks for you response. It solves the problem that event occurs each time we click an item of list box but it did not return which item is selected and also does not select any item.
My requirement is
  1. Select an item from list
  2. Find selected item in class and fetch data of selected item
  3. If user click on selected item again it should fetch data again
0
Genady Sergeev
Telerik team
answered on 31 Mar 2010, 02:04 PM
Hello Saima Gul,

In the click handler you can obtain the SelectedItem the following way:

void hiddenSubmit_Click(object sender, EventArgs e)
 {
     var selectedItem = RadListBox1.SelectedItem;
     Response.Write(selectedItem.Text);
     //Use the selected item
 }

On subsequent user click you can once again obtain the selected item using the SelectedItem property. I suppose that this will work with your requirements.

Sincerely yours,
Genady Sergeev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ListBox
Asked by
Saima Gul
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Saima Gul
Top achievements
Rank 1
Share this question
or