I need to use Cascading combo boxes for that to avoid post backs i selected Load on demand Ajax Combo....
for first time selected values its working fine..when i will change item in the first combo-box the second combo box items are not get updated.my code is below
for first time selected values its working fine..when i will change item in the first combo-box the second combo box items are not get updated.my code is below
<
telerik:RadComboBox
ID
=
"RadComboState"
runat
=
"server"
Width
=
"250px"
Height
=
"150px"
EmptyMessage
=
"Select a state"
EnableLoadOnDemand
=
"True"
ShowMoreResultsBox
=
"true"
EnableVirtualScrolling
=
"true"
OnItemsRequested
=
"RadComboState_ItemsRequested"
>
</
telerik:RadComboBox
>
<
telerik:RadComboBox
ID
=
"RadComboInstitution"
runat
=
"server"
Width
=
"250px"
Height
=
"150px"
EmptyMessage
=
"Select an institution"
EnableLoadOnDemand
=
"True"
ShowMoreResultsBox
=
"true"
EnableVirtualScrolling
=
"true"
OnItemsRequested
=
"RadComboInstitution_ItemsRequested"
OnClientItemsRequesting
=
"GetSelectedState"
>
</
telerik:RadComboBox
>
function
GetSelectedState(sender, eventArgs) {
var
SelectedState;
var
combo = Telerik.Web.UI.RadComboBox.ComboBoxes[0];
SelectedState = combo.get_value();
var
context = eventArgs.get_context();
context[
"StateId"
] = SelectedState;
}
protected
void
RadComboState_ItemsRequested(
object
o, RadComboBoxItemsRequestedEventArgs e)
{
RadComboState.Items.Clear();
DataSet data = PoulateStates();
if
(data.Tables.Count > 0 && data.Tables[0].Rows[0][0].ToString() ==
"0"
)
{
int
itemOffset = e.NumberOfItems;
int
endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Tables[0].Rows.Count);
e.EndOfItems = endOffset == data.Tables[0].Rows.Count;
for
(
int
i = itemOffset; i < endOffset; i++)
{
RadComboState.Items.Add(
new
RadComboBoxItem(data.Tables[0].Rows[i][
"State_Name"
].ToString(),
data.Tables[0].Rows[i][
"intPkVal"
].ToString()));
}
e.Message = GetStatusMessage(endOffset, data.Tables[0].Rows.Count);
}
else
{
RadComboBoxItem item =
new
RadComboBoxItem();
item.Value =
"-1"
;
if
(Session[
"COUNTRY"
] !=
null
&& Session[
"COUNTRY"
].ToString().ToUpper() ==
"MARSHALL ISLANDS"
)
item.Text =
"No Island Exists"
;
else
item.Text =
"No State Exists"
;
RadComboState.Items.Add(item);
}
}
protected
void
RadComboInstitution_ItemsRequested(
object
o, RadComboBoxItemsRequestedEventArgs e)
{
RadComboInstitution.Items.Clear();
DataSet Institution =
new
DataSet();
try
{
string
StateId = e.Context[
"StateId"
].ToString();
Institution = populateInstitution(StateId);
if
(Institution.Tables[0].Rows[0][0].ToString() ==
"0"
)
{
int
itemOffset = e.NumberOfItems;
int
endOffset = Math.Min(itemOffset + ItemsPerRequest, Institution.Tables[0].Rows.Count);
e.EndOfItems = endOffset == Institution.Tables[0].Rows.Count;
for
(
int
i = itemOffset; i < endOffset; i++)
{
RadComboInstitution.Items.Add(
new
RadComboBoxItem(Institution.Tables[0].Rows[i][
"Institution_Name"
].ToString(),
Institution.Tables[0].Rows[i][
"InstitutionId"
].ToString()));
}
e.Message = GetStatusMessage(endOffset, Institution.Tables[0].Rows.Count);
}
else
{
RadComboBoxItem item =
new
RadComboBoxItem();
item.Value =
"-1"
;
item.Text =
"No Institution Exists"
;
RadComboInstitution.Items.Add(item);
}
}
catch
(Exception ex)
{
}
}