Implementing cascading DropDownList binding in a templated control

后端 未结 4 606
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 04:21

I have 2 DropDownList controls on my form, the second of which uses the SelectedValue of the first as one of its binding parameters.

Both <

4条回答
  •  梦谈多话
    2021-01-03 04:43

    This is an issue when we use cascading dropdownlist in Databinding Controls like DetailsView/FormView and I have faced it many times. You have to remove the Binding Expression from your Second Dropdownlist SelectedValue='<%# Bind("AttorneyID") %>', then it will work.

    Secondly if you remove the Binding expression, you have to pass the value manually in FormView ItemInserting Event. e.g.

     protected void frmAsset_ItemInserting(object sender, FormViewInsertEventArgs e)
     {
        eValues["AttorneyID"] = ((DropDownList)((FormView)sender).FindControl("ddlAttorny")).SelectedValue;
     }
    

提交回复
热议问题