Hi,
I want to find a DropDownList Control inside ItemUpdating event of DetailsView control. I have used following methods to do the same, but none of them are working
DropDownList drp_SName = (DropDownList)dv_UnshippedOrders.Rows[0].Cells[0].FindControl("drp_Name");
DropDownList drp_SName = (DropDownList)dv_UnshippedOrders.FindControl("drp_Name");
Kindly help me out in this regard.
Saineshwar BageriPosted Nov 20, 2014, 12:02 AM
Joginder BangerPosted Nov 19, 2014, 11:59 PM
protected void detailsview_RowUpdating(object sender, DetailsViewUpdateEventArgs e)
{
Dropdownlist ddlname = (Dropdownlist)yourdetialsname.Rows[e.RowIndex].FindControl("idname");
detailsview.EditIndex = -1;
BindCountry();
}
Saineshwar BageriPosted Nov 19, 2014, 11:52 PM
protected void DetailsView1_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{
string Empid = e.CommandArgument.ToString();
TextBox txtname = (TextBox)DetailsView1.FindControl("txtEmpname");
TextBox txtEmp_Address = (TextBox)DetailsView1.FindControl("txtEmp_Address");
TextBox txtEmp_Department = (TextBox)DetailsView1.FindControl("txtEmp_Department");
SqlCommand cmd = new SqlCommand("Usp_Insert_Update", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EmpId", Empid);
cmd.Parameters.AddWithValue("@Emp_Name",txtname.Text);
cmd.Parameters.AddWithValue("@Emp_Address",txtEmp_Address.Text);
cmd.Parameters.AddWithValue("@Emp_Department",txtEmp_Department.Text);
cmd.Parameters.AddWithValue("@QueryID", 2);
con.Open();
cmd.ExecuteScalar();
con.Close();
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
AllDetailsDataBind();
}
For more Details you can visit this site and check.
http://dotnet-sai.blogspot.in/p/all-gridview-example.html