I have two combobox, infoCat and childCat
When the ParentCombo selectedindex is changed, I want ChildCombo to re-databind (as the data is obtained through the database).
I'm having a difficulty with this. On other post, you said that I can use ItemsRequested event.. But it seems the demo code is outdated..
the script in the aspx file doesn't make sense..
within ASPX.VB File:
Protected Sub infoCat_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.WebControls.RadComboBoxSelectedIndexChangedEventArgs) Handles infoCat.SelectedIndexChanged
PopulateChildIDs()
End Sub
Protected Sub infoCat_ItemsRequested(ByVal o As Object, ByVal e As Telerik.WebControls.RadComboBoxItemsRequestedEventArgs) Handles infoCat.ItemsRequested
PopulateInfoIDs()
End Sub
Protected Sub childCat_ItemsRequested(ByVal o As Object, ByVal e As Telerik.WebControls.RadComboBoxItemsRequestedEventArgs) Handles childCat.ItemsRequested
PopulateChildIDs()
End Sub
Private
Sub PopulateInfoIDs()
sql =
"SELECT category, category As value FROM InfoCategory"
dbCommand = db.GetSqlStringCommand(sql)
Dim ds As DataSet = db.ExecuteDataSet(dbCommand)
infoCat.DataSource = ds
infoCat.DataTextField =
"category"
infoCat.DataValueField =
"value"
infoCat.DataBind()
If infoCat.Items.Count > 0 Then
infoCat.SelectedIndex = 0
End If
Private Sub PopulateChildIDs()
If infoCat.SelectedIndex <> -1 Then
sql =
"SELECT title, title As value FROM Information WHERE category ='" & infoCat.SelectedValue & "'"
dbCommand = db.GetSqlStringCommand(sql)
Dim ds As DataSet = db.ExecuteDataSet(dbCommand)
childCat.DataSource = ds
childCat.DataTextField =
"title"
childCat.DataValueField =
"value"
childCat.DataBind()
If childCat.Items.Count > 0 Then
childCat.SelectedIndex = -1
End If
On ASPX File:
<div class="editdropdown2">
<radC:RadComboBox ID="infoCat" runat="server" AutoPostBack="True" Skin="ClassicBlue" Width="582px">
</radC:RadComboBox>
<radC:RadComboBox ID="childCat" runat="server" AutoPostBack="True" Skin="ClassicBlue" Width="582px" OnClientItemsRequested="ItemsLoaded">
</radC:RadComboBox>
</div>
I tried using script
<script type="text/javascript">
var childCombo = <%= childCat.ClientID %>;
function PopulateChildIDs(item)
{
childCombo.SetText(
"Loading...");
childCombo.RequestItems(item.Value,
false);
}
function ItemsLoaded(combo)
{
if (combo.Items.length > 0)
{
combo.SetText(combo.Items[0].Text);
combo.Items[0].Highlight();
}
combo.ShowDropDown();
}
</script>
but not working. How come in the demo it uses (item) <-- where is the argument used..?
Can you provide me some guidance/script/solution to this?
Thanks,
Andreas