I have one dataAccessLayer.cs which supply edit, delete, update method; one GridView control to show limited data; one DetailsView control to show more details value. When i press select button in gridview and then detailsView fill detail value. But I create dropdownlist on the codeBehind to show data in detailsView. so far there are no bug but When I want to edit data in detailView program do not catch dropdownlist value for editing
protected void DetailsView1_DataBound(object sender, EventArgs e)
{
if (DetailsView1.CurrentMode == DetailsViewMode.Edit)
{
DropDownList dropDownList = (DropDownList)DetailsView1.FindControl("DropDownList2");
dropDownList.DataSource = ss.DataTableMtd("spGetAllMarkaIdName");
dropDownList.DataTextField = "Marka_Name";
dropDownList.DataValueField = "Marka_Name";
dropDownList.DataBind();
}
}
At last I find the answer.
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
ObjectDataSource2.UpdateParameters["MarkaName"].DefaultValue =
((DropDownList)DetailsView1.FindControl("DropDownList2")).SelectedValue;
}