
protected void ddlMake_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) | |
{ | |
ViewState["Make"] = e.Text; | |
} |
Forgive me if this is an extremely easy question but for some reason I cannot get the SelectedValue rather than the SelectedText from the RadCombo in the SelectedIndesChanged event. Can someone please help me find where this may be? e.Text is the only thing that appears to be accessible. My ID values are the hidden piece I need.
Thanks in advance.
Doug
14 Answers, 1 is accepted
Please try using RadComboBox.SelectedValue property in the event handler to get the value of the currently selected item.
Please let me know how it goes.
Sincerely yours,
Simon
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Thanks.
Doug

I would expect the RadComboBoxSelectedIndexChangedEventArgs to include .Text, .Value and .Index properties at the least.
.SelectedIndex() is essential in my understanding of how to make synchronized comboboxes work properly via AJAX.
If I had a selected Index collection, I could use the NeedsDataSource to rely on the data being populated during the ajax call, even if it is reloaded.
Having support for Multiselection, i.e. SelectedIndex() instead of .SelectedIndex is important as well.
to further expand on this...
I have a radComboBox on a Master Page.
The Master Page has a RadAjaxManager
The radComboBox is set to AutoPostBack=True
The AjaxManager is set so that FacilitySelector Updates FacilitySelector
This code does not work...
Private Sub FacilitySelector_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles FacilitySelector.SelectedIndexChanged
Dim cbo = TryCast(o, Telerik.Web.UI.RadComboBox)
If cbo IsNot Nothing Then
Try
If Session("FacilityUID") <> CInt(cbo.SelectedValue) Then
Session("FacilityUID") = CInt(cbo.SelectedValue)
End If
Catch ex As Exception
End Try
End If
End Sub
The FIRST time it does in fact work, it sets the sessionvar and updates the control.
Subsequent Changes do NOT work because the SelectedIndex is always the same, the first item selected.
I have tried setting EnableViewState both ways, and various other things but I cannot access he newly selected item after the first selection.
I DO NOT want to do this with JavaScript, this should be a server-side function that works with AjaxManager.
e.Text is Correct showing the newly selected text and so does the following code, but this just seems like a Kludge since e.Text is not considered Unique (but in fact "most likely is" in my particular case).
Private Sub FacilitySelector_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles FacilitySelector.SelectedIndexChanged
Dim cbo = TryCast(o, Telerik.Web.UI.RadComboBox)
If cbo IsNot Nothing Then
Try
Dim item As Integer = cbo.FindItemIndexByText(e.Text)
cbo.SelectedIndex = item
If Session("FacilityUID") <> cbo.SelectedValue Then
Session("FacilityUID") = cbo.SelectedValue
End If
Catch ex As Exception
End Try
End If
End Sub
We have already planned the implementation of the RadComboBox's Value as a property of the SelectedIndexChanged event arguments. However, the addition of the Index property needs further consideration.
Now, to your specific case. I created a sample project using the configuration you have described. It worked as expected. Please see the attached project for a reference.
Best wishes,
Simon
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

Our developers will surely include this property in the forthcoming Q1 release due by the end of this month. I hope this timeframe is acceptable for you.
Regards,
Nick
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center


I am in similar situation where in I need the value of the selected item. Is there anyupdates on this?
"RadcomboBox.SelectedValue" gives the text but not the corresponding value.

Kishan,
Are you trying to find the value during the SelectedIndexChanged event? If so, I find that the below code works for me to return the newly selected value. Also, you may want to ensure that your DataValueField is setup to be the field you wish to return. It sounds like maybe your DataValueField and DataTextField properties are setup to be against the same field from the datasource.
protected void RadComboBox1_SelectedIndexChanged(object source, RadComboBoxSelectedIndexChangedEventArgs e) |
{ |
string comboValue = e.Value; |
} |
I hope this helps,
Casey

Thanks a ton!!I'm relieved.....It worked!!!!
Cheers,
Kishan


Such an issue is not expected, please make sure that you have mentioned the Value for the items in the RadComboBox. Please have a look into the sample code snippet which works fine at my end.
ASPX:
<
telerik:RadComboBox
ID
=
"rcboCountry"
runat
=
"server"
EmptyMessage
=
"--select--"
DataSourceID
=
"SqlDataSource1"
AutoPostBack
=
"true"
DataTextField
=
"CountryName"
OnSelectedIndexChanged
=
"rcboCountry_SelectedIndexChanged"
DataValueField
=
"CountryId"
>
</
telerik:RadComboBox
>
Please provide your full code if it doesn't help.
Thanks,
Shinu.

<
telerik:RadComboBox
ID
=
"cmbItemMaster"
Width
=
"90%"
AutoPostBack
=
"true"
runat
=
"server"
AllowCustomText
=
"true"
Filter
=
"Contains"
EmptyMessage
=
"select"
OnSelectedIndexChanged
=
"cmbItemMaster_SelectedIndexChanged"
></
telerik:RadComboBox
>
protected void LoadItemMaster()
{
cmbItemMaster.DataSource = objItemMasterDAO.GetAllItemMasters();
cmbItemMaster.DataValueField = "ItemMasterID";
cmbItemMaster.DataTextField = "ItemMasterName";
cmbItemMaster.DataBind();
}
protected void cmbItemMaster_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
if (e.Value != "")
{
LoadItemMaster(e.Value);
}
}

Please have a look into the sample code snippet which works fine at my end.
ASPX:
<
telerik:RadComboBox
ID
=
"rcboItems"
runat
=
"server"
AllowCustomText
=
"true"
Filter
=
"Contains"
EmptyMessage
=
"select"
AutoPostBack
=
"true"
OnSelectedIndexChanged
=
"rcboCountry_SelectedIndexChanged"
>
</
telerik:RadComboBox
>
C#:
protected
void
Page_init(
object
sender, EventArgs e)
{
rcboItems.DataSource = GetData();
rcboItems.DataValueField =
"ItemMasterID"
;
rcboItems.DataTextField =
"ItemMasterName"
;
rcboItems.DataBind();
}
protected
DataTable GetData()
{
DataTable dtcboItems =
new
DataTable();
dtcboItems.Columns.Add(
new
DataColumn(
"ItemMasterID"
));
dtcboItems.Columns.Add(
new
DataColumn(
"ItemMasterName"
));
dtcboItems.Rows.Add(
new
object
[] { 1,
"Canada"
});
dtcboItems.Rows.Add(
new
object
[] { 2,
"Saudi Arabia"
});
dtcboItems.Rows.Add(
new
object
[] { 3,
"Mexico"
});
dtcboItems.Rows.Add(
new
object
[] { 4,
"Venezuela"
});
return
dtcboItems;
}
protected
void
rcboCountry_SelectedIndexChanged(
object
sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
string
selectedValue = e.Value;
}
Thanks,
Shinu.