Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

selected value

Posted on 2011-09-30
10
Medium Priority
?
251 Views
Last Modified: 2012-05-12
<telerik:RadComboBox ID=" to" runat="server" Width="99%" AutoCompleteSeparator=";"
                    DataSourceID="dsSelect" DataTextField="Name" DataValueField="ID"
                    MarkFirstMatch="true" AllowCustomText="true"  
                    ShowDropDownOnTextboxClick="false" ShowToggleImage="false" />

when I have more than one item on selected on, using .SelectedValue = shows ""   why this is like that
0
Comment
Question by:1jaws
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 16

Expert Comment

by:disrupt
ID: 36894547
0
 

Author Comment

by:1jaws
ID: 36894576
I know has that and gives the text but I need a values... so if I use like that

protected void RadComboBox1_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
        {
            //set the Text and Value property of every item
            //here you can set any other properties like Enabled, ToolTip, Visible, etc.
            e.Item.Text = ((DataRowView)e.Item.DataItem)["ContactName"].ToString() ;
            e.Item.Value = ((DataRowView)e.Item.DataItem)["CustomerID"].ToString();
        }

it gives me values but I dont need on the Itemdatabound event.. because I am after when user selects have multiple values already done selecting.... which event I should try..
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 36895549
no event needed... get them on page_load

(why people use RadComboBox1 as id of the control? you should say rcbContacts or something like that, best practices...)

Useful Links:

http://www.telerik.com/help/aspnet-ajax/allmembers_t_telerik_web_ui_radcomboboxitem.html
http://msdn.microsoft.com/en-us/library/ttw7t8t6.aspx
foreach (RadComboBoxItem item in RadComboBox1) {
  if (item.Selected) doSomething(item);
}

...

void doSomething(RadComboBoxItem item){
  Response.Write("<li>[" + item.Index + "] " + item.Value + " : " + item.Text);
}

Open in new window

0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 

Author Comment

by:1jaws
ID: 36896089
thank you for your reply.  instead of line 8, since all I need item.value , and I am interested in getting multiple values, how can I combine values in under one statement.. For ex. my combobox item's value comes back as 1 , than 4, then 8   how can I combine those as totalString = {1,4,8} because I need to pass this value to stored proc. as a varchar string than probably use a split function to separete to values to 1
    4
    8  again  for each customer ID...
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 36896108
here it is:

string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
  v = (v=="")?item.Value.ToString():","+item.Value.ToString();
}
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 36896117
or this:

string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
  v = ((v=="")?"":",") + item.Value.ToString();
}
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 36896119
or for c# dummies :)

string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
  if (v == "") v = item.Value.ToString(); else v = v + "," + item.Value.ToString();
}
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 36896128
oops I forgot to add the condition
wrap inner statement with

if (item.selected) {
...
}
0
 
LVL 59

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 36896130
one fix

v = ((v == "") ? "" : ",") + item.Value.ToString();
-->
v = v + ((v == "") ? "" : ",") + item.Value.ToString();
0
 

Author Closing Comment

by:1jaws
ID: 36896330
Thank you so much!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question