1jaws
asked on
selected value
<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
DataSourceID="dsSelect" DataTextField="Name" DataValueField="ID"
MarkFirstMatch="true" AllowCustomText="true"
ShowDropDownOnTextboxClick
when I have more than one item on selected on, using .SelectedValue = shows "" why this is like that
ASKER
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.DataI tem)["Cont actName"]. ToString() ;
e.Item.Value = ((DataRowView)e.Item.DataI tem)["Cust omerID"].T oString();
}
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..
protected void RadComboBox1_ItemDataBound
{
//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.DataI
e.Item.Value = ((DataRowView)e.Item.DataI
}
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..
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
(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);
}
ASKER
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...
4
8 again for each customer ID...
here it is:
string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
v = (v=="")?item.Value.ToStrin g():","+it em.Value.T oString();
}
string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
v = (v=="")?item.Value.ToStrin
}
or this:
string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
v = ((v=="")?"":",") + item.Value.ToString();
}
string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
v = ((v=="")?"":",") + item.Value.ToString();
}
or for c# dummies :)
string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
if (v == "") v = item.Value.ToString(); else v = v + "," + item.Value.ToString();
}
string v ="";
foreach (RadComboBoxItem item in RadComboBox1.items) {
if (v == "") v = item.Value.ToString(); else v = v + "," + item.Value.ToString();
}
oops I forgot to add the condition
wrap inner statement with
if (item.selected) {
...
}
wrap inner statement with
if (item.selected) {
...
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much!!!
look at this working example:
http://demos.mcmscontrols.com/ASPNET/Combobox/Examples/Functionality/MultipleItemsAutoComplete/DefaultCS.aspx