Hi everybody,
I'm trying to put 2 RadComboBoxes inside an asp:repeater. what I'd like to achieve is that on each line when I select a value from the first combobox It load me the value in my second combo.
can somebody help me? I just would like to know if it's possible to do such a thing, and if so if somebody could give me an example!
Thank you very much
Raphael
I'm trying to put 2 RadComboBoxes inside an asp:repeater. what I'd like to achieve is that on each line when I select a value from the first combobox It load me the value in my second combo.
can somebody help me? I just would like to know if it's possible to do such a thing, and if so if somebody could give me an example!
Thank you very much
Raphael
6 Answers, 1 is accepted
0
Accepted
Hi raphael,
Here is one approach: subscribe to the OnClientSelectedIndexChanged event of the first combobox and in its event handler find the corresponding second combobox and call the requestItems client side method.
Here is a sample code:
I hope that this will get you started.
Best wishes,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Here is one approach: subscribe to the OnClientSelectedIndexChanged event of the first combobox and in its event handler find the corresponding second combobox and call the requestItems client side method.
Here is a sample code:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="AccessDataSource1" > |
<ItemTemplate> |
<telerik:RadComboBox ID="RadComboBox1" runat="server" |
Skin="Hay" |
OnClientSelectedIndexChanged="OnClientSelectedIndexChangedHandler" |
DataTextField="ID" |
SelectedValue='<%# Bind("ID") %>' |
DataValueField="ID" |
DataSourceID="AccessDataSource1"> |
</telerik:RadComboBox> <br /> |
<telerik:RadComboBox ID="RadComboBox2" runat="server" |
DataTextField="Name" |
SelectedValue='<%# Bind("Name") %>' |
DataValueField="Name" |
AllowCustomText="true" |
DataSourceID="AccessDataSource1" |
Skin="Sunset"> |
</telerik:RadComboBox> <br /><br /> |
</ItemTemplate> |
</asp:Repeater> |
<script type="text/javascript"> |
function OnClientSelectedIndexChangedHandler(sender, eventArgs) |
{ |
var comboArray = Telerik.Web.UI.RadComboBox.ComboBoxes; |
var i; |
for (i = 0; i < comboArray.length; i++) |
{ |
if (comboArray[i] == sender) |
{ |
break; |
} |
} |
var nextCombo = comboArray[i + 1]; |
nextCombo.requestItems(eventArgs.get_item().get_value(), false); |
} |
</script> |
I hope that this will get you started.
Best wishes,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

raphael
Top achievements
Rank 1
answered on 14 Oct 2008, 09:27 AM
hi Veselin,
Thank you for the quick answer, that solve part of my problem.
Now I have another one... inside the itemsrequested function I try to bind the right set of Data to my child combobox.
I get back the value from the db, I bind them to my combobox but when I get back on my page the combo is still empty
Thank you for the quick answer, that solve part of my problem.
Now I have another one... inside the itemsrequested function I try to bind the right set of Data to my child combobox.
I get back the value from the db, I bind them to my combobox but when I get back on my page the combo is still empty
protected void RadComboBox2_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
RadComboBox rcb = (RadComboBox)o;
AccountFacade facade = new AccountFacade();
DataSet ds = facade.GetBanksForAccount(int.Parse(e.Text));
rcb.DataSource = ds;
rcb.DataBind();
}
Do i miss something or do somenthing wrong?
Thank you Raphael
0
Hi raphael,
The code looks correct.
I would suggest that you put a breakpoint in this event handler and debug the application. Check if it enters into that handler and does the dataset has data?
Regards,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The code looks correct.
I would suggest that you put a breakpoint in this event handler and debug the application. Check if it enters into that handler and does the dataset has data?
Regards,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

raphael
Top achievements
Rank 1
answered on 14 Oct 2008, 12:11 PM
I've already checked if the event fires with a break point, and the dataset has some values inside.
I noticed that using radAjaxPanel the comboBox gets populated for an istant but after the page gets loaded the comboBox is empty again.
I check if there where some other functions that clear combo but there aren't
after selecting a value from the first combo the page load event fires, than the itemsRequestes event fire an than the page_load event fires again. Both time in the page_load nothing happens beacause at the begining of the event I putted the control if the page.ispostback control.
I've tryied to populate the combo adding every dataset element mannualy (combobox.items.add()) but I get the same behaviour.
I noticed that using radAjaxPanel the comboBox gets populated for an istant but after the page gets loaded the comboBox is empty again.
I check if there where some other functions that clear combo but there aren't
after selecting a value from the first combo the page load event fires, than the itemsRequestes event fire an than the page_load event fires again. Both time in the page_load nothing happens beacause at the begining of the event I putted the control if the page.ispostback control.
I've tryied to populate the combo adding every dataset element mannualy (combobox.items.add()) but I get the same behaviour.
0
Hi raphael,
The page_load event should not be fired after the ItemsRequested event handler. This is strange and could be the reason for the problem. I suggest that you open a support ticket and send us a sample project demonstrating the issue.
Thanks
Greetings,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The page_load event should not be fired after the ItemsRequested event handler. This is strange and could be the reason for the problem. I suggest that you open a support ticket and send us a sample project demonstrating the issue.
Thanks
Greetings,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

raphael
Top achievements
Rank 1
answered on 14 Oct 2008, 12:40 PM
Ok Thanx to your post I solved my problem! before posting my problem on the forum I tryied out some possible solutions, and after that I forgot to set to false the autopostback attribute.
Thank you very much and sorry
Raphael
Thank you very much and sorry
Raphael