Hello, I am having an issue with a custom edit form for rad grid. I have cascading drop downs in an edit form template, basically, user selects a state and then the city dropdown pre populates with cities in that state. I bind the initial item lists in the ItemDataBound event like I saw in some examples. I have no issues pre populating the drop downs with the initial lists and selected values, however if a user changes the value of the States drop down, it causes a postback (which it should) but it resets the whole form back to the original values.
So the edit form populates correctly, user changes some text boxes etc... but if they select a different state the whole form resets. Is there anything special I need to do to use cascading combo boxes with async postbacks in my edit form. I have read some other posts but I cant find anything that replicates the issue I am having.
<
MasterTableView
EditMode
=
"PopUp"
EditFormSettings-PopUpSettings-Width
=
"600"
DataKeyNames
=
"Id"
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
table
cellspacing
=
"8"
>
<
tr
>
<
td
class
=
"style2"
>Title:</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"txtTitle"
Visible
=
"true"
Text='<%# DataBinder.Eval( Container, "DataItem.Title" ) %>' MaxLength="100" Width="400" runat="server">
</
telerik:RadTextBox
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"style1"
valign
=
"top"
>State:</
td
>
<
td
>
<
telerik:RadComboBox
ID
=
"RadComboBoxState"
runat
=
"server"
>
</
telerik:RadComboBox
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"style1"
valign
=
"top"
>City:
</
td
>
<
td
>
<
telerik:RadComboBox
ID
=
"RadComboBoxCity"
runat
=
"server"
>
</
telerik:RadComboBox
>
</
td
>
</
tr
>
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem editFormItem = e.Item
as
GridEditFormItem;
GridDataItem parentItem = editFormItem.ParentItem;
Literal debug = (Literal)editFormItem.FindControl(
"ltr_debug"
);
int
_EntityId = Convert.ToInt32(parentItem[
"OwnerEntityId"
].Text);
//*******************************
//Load states
//*******************************
RadComboBox cbStates = editFormItem.FindControl(
"RadComboBoxState"
)
as
RadComboBox;
DataTable dtStates = ApplicationInterface.GetActiveStates();
cbStates.DataSource = dtStates;
cbStates.DataValueField =
"id"
;
cbStates.DataTextField =
"name"
;
cbStates.DataBind();
cbStates.SelectedValue = parentItem[
"SelectedState"
].Text;
cbStates.AutoPostBack=
true
;
cbStates.SelectedIndexChanged +=
new
System.EventHandler(StateSelected);
//*******************************
//Load cities
//*******************************
RadComboBox lbCities= (RadComboBox)editFormItem.FindControl(
"RadComboBoxCity"
);
DataTable dtCitiesByState = ApplicationInterface.GetCitiesForState(parentItem[
"SelectedState"
].Text);
lbCities.DataSource = dtCitiesByState;
lbCities.AutoPostBack =
true
;
lbCities.DataValueField =
"id"
;
lbCities.DataTextField =
"name"
;
lbCities.DataBind();
lbCities.SelectedValue = parentItem[
"SelectedCity"
].Text;
}
}
protected
void
StateSelected(
object
sender, EventArgs e)
{
RadComboBox dc = (RadComboBox)sender;
GridEditFormItem editedItem = dc.NamingContainer
as
GridEditFormItem;
RadComboBox cities=editedItem.FindControl(
"RadComboBoxCity"
)
as
RadComboBox;
...
..Binding code here
}
So the edit form populates correctly, user changes some text boxes etc... but if they select a different state the whole form resets. Is there anything special I need to do to use cascading combo boxes with async postbacks in my edit form. I have read some other posts but I cant find anything that replicates the issue I am having.