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

Regadring AJAX ASP.NET RadComboBox

1 Answer 62 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
keerthi
Top achievements
Rank 1
keerthi asked on 24 Oct 2008, 06:41 PM
Hi,

I am very new to Telerik controls,
i am facing a problem where i have two RadDropDowns,while selecting the first dropdown,second dropdownlist is populated.

While in button click event i am not able to get second drop down selected value,eventhough dropdown is having values before the click event.

<rad:RadComboBox ID="RadComboBox1" runat="server" Width="200px" Height="115px" TabIndex="1"OnClientSelectedIndexChanging="LoadOrganizations" OnItemsRequested="RadComboBox1_ItemsRequested"EnableLoadOnDemand="True" AllowCustomText="False" ItemRequestTimeout="500" MarkFirstMatch="True">
<Items> </Items>
</rad:RadComboBox>
<rad:RadComboBox ID="RadComboBox2" runat="server" Width="200px" Height="115px" TabIndex="2"OnClientItemsRequested="ItemsLoaded"OnItemsRequested="RadComboBox2_ItemsRequested">
<Items></Items>
</rad:RadComboBox>

 

function LoadOrganizations(combo, eventarqs) {
var countriesCombo = $find("RadComboBox2");
var item = eventarqs.get_item();
countriesCombo.set_text(
"Loading...");
if (item.get_index() > 0) {countriesCombo.requestItems(item.get_value(), false); }
else {countriesCombo.set_text(" No Records Exist ");
countriesCombo.clearItems();}
}

 

 

function ItemsLoaded(combo, eventarqs) {
var countriesCombo = $find("RadComboBox2");
if (combo.get_items().get_count() > 0) {
combo.set_text(combo.get_items().getItem(0).get_text());
combo.get_items().getItem(0).highlight();
}
else {
countriesCombo.set_text(
" No Records Exist ");
countriesCombo.clearItems();
}
countriesCombo.commitChanges();
//combo.showDropDown(); }
C#

 

protected

 

void Page_Load(object sender, EventArgs e){
if (!IsPostBack){
LoadJurisdictions(); // ;db call for jurisdictions
RadComboBox1.Items.Insert(0,
new RadComboBoxItem("- Select Jurisdiction -"));
}} 

 

 

protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){
LoadJurisdictions(); //dbcall for juris
}

 

 

protected void RadComboBox2_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){
LoadOrg(e.Text);// db call for org
}

 

protected

 

void btnsubmit_Click(object sender, EventArgs e){
RadComboBoxItem r1 = RadComboBox1.SelectedItem;

RadComboBoxItem r2 = RadComboBox2.SelectedItem;

 

// getting null for  r2
}

 


 

1 Answer, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 27 Oct 2008, 07:17 AM
Hello,

RadComboBoxItems are not persisted on the server if they are loaded on demand. I suggest you use the SelectedValue and Text properties of the controls instead of the SelectedItem property.

For example:
protected void btnsubmit_Click(object sender, EventArgs e){   
string r1 = RadComboBox1.SelectedValue;  
 
string r2 = RadComboBox2.SelectedValue;  
// getting null for  r2  
}  
 

For more details you can read our help article.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
keerthi
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Share this question
or