Hi,
I'm simply looking to return the text from a listview where I have an id for the key field and a name field which is what is displayed. I thought this would be relatively simple but keep failing.
Also I can't seem to find a way to get the first item selected by default when the page loads.
I thought for sue I could find something like this in the forums but came up empty.
Thanks
I'm simply looking to return the text from a listview where I have an id for the key field and a name field which is what is displayed. I thought this would be relatively simple but keep failing.
Also I can't seem to find a way to get the first item selected by default when the page loads.
I thought for sue I could find something like this in the forums but came up empty.
Thanks
4 Answers, 1 is accepted
0

Dana
Top achievements
Rank 1
answered on 30 Jan 2014, 03:06 PM
Was able to answer the first part by sifting through the example code. Found this:
RadListView1.SelectedItems[0].ExtractValues(values);
string make = values["Make"].ToString();
string model = values["Model"].ToString();
but things must have changed since when I tried to do it I couldn't find ExtractValues in the intellisense. But this worked:
string temp = RadListView1.SelectedItems[0].Text
Certainly simpler! Now if I could only figure out how to programmatically select the first item in the list box. I found some suggestions from other posts that so far haven't worked for me.
RadListView1.SelectedItems[0].ExtractValues(values);
string make = values["Make"].ToString();
string model = values["Model"].ToString();
but things must have changed since when I tried to do it I couldn't find ExtractValues in the intellisense. But this worked:
string temp = RadListView1.SelectedItems[0].Text
Certainly simpler! Now if I could only figure out how to programmatically select the first item in the list box. I found some suggestions from other posts that so far haven't worked for me.
0
Hello Dana,
I have created a sample RadListView web site to demonstrate different approaches to achieve the requested functionality. Please run the attached application and let me know if it helps you.
Regards,
Eyup
Telerik
I have created a sample RadListView web site to demonstrate different approaches to achieve the requested functionality. Please run the attached application and let me know if it helps you.
Regards,
Eyup
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
0

Dana
Top achievements
Rank 1
answered on 06 Feb 2014, 10:09 PM
Forgive me, but I tried to put it all into a solution and am clearly missing something because it didn't work.
Incidentally to clarify the issue I'm having with the listview, it appears to always be behind by one click. In other words, even though I see the item in the listview, the text box that I have linked to it by setting its value to the first item in the listview is apparently updated after the listview completes. In fact, the first time through always generated an error. Here's the code:
protected void RadListBox_Depts_SelectedIndexChanged(object sender, EventArgs e)
{
RadListBox_UserName.SelectedIndex = 0;
if (RadListBox_UserName.SelectedIndex !=-1)
{
labelUserName.Text = RadListBox_UserName.SelectedItems[0].Text;
}
I've tried all the other methods and still end up one click behind.
Incidentally to clarify the issue I'm having with the listview, it appears to always be behind by one click. In other words, even though I see the item in the listview, the text box that I have linked to it by setting its value to the first item in the listview is apparently updated after the listview completes. In fact, the first time through always generated an error. Here's the code:
protected void RadListBox_Depts_SelectedIndexChanged(object sender, EventArgs e)
{
RadListBox_UserName.SelectedIndex = 0;
if (RadListBox_UserName.SelectedIndex !=-1)
{
labelUserName.Text = RadListBox_UserName.SelectedItems[0].Text;
}
I've tried all the other methods and still end up one click behind.
0
Hi Dana,
Do you use RadListView or RadListBox? Please note that they are entirely separate controls.
I suppose you are using RadListView. In that case, the suggested approaches in the provided web site should work correctly. Can you please verify that you have run the web site and it works as expected?
It would be great if you modify the RadListViewSelectionFirstItem.zip to demonstrate the issue and open a support ticket to send it back to us, along with detailed steps and a sample video. Thus, we will be able to further debug and analyze the project and suggest a proper solution.
Regards,
Eyup
Telerik
Do you use RadListView or RadListBox? Please note that they are entirely separate controls.
I suppose you are using RadListView. In that case, the suggested approaches in the provided web site should work correctly. Can you please verify that you have run the web site and it works as expected?
It would be great if you modify the RadListViewSelectionFirstItem.zip to demonstrate the issue and open a support ticket to send it back to us, along with detailed steps and a sample video. Thus, we will be able to further debug and analyze the project and suggest a proper solution.
Regards,
Eyup
Telerik
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 UI for ASP.NET AJAX, subscribe to the blog feed now.