protected void GridViewDepartment_RowUpdating(object sender, GridViewUpdateEventArgs e) { getConnection = connection.SetConnection(); GridView GridViewDepartment = (GridView)sender; GridViewDepartment.EditIndex = e.RowIndex; GridViewDepartment.DataSource = departmentTable; GridViewDepartment.DataBind(); int DepartmentID = (int)GridViewDepartment.DataKeys[e.RowIndex].Value; DropDownList ddlManager = ((DropDownList)GridViewDepartment.Rows[e.RowIndex].FindControl("ddlDepartManager")); string AssignNewManagr = ddlManager.SelectedItem.Text.ToString(); // this selecting only "select" 0th item only even on changing index string AssignNewActive = ((DropDownList)GridViewDepartment.Rows[e.RowIndex].FindControl("DropDownListActive")).SelectedItem.ToString(); string SPUPDateDepartment = "SPModifyDepartment"; SqlCommand UPDateCommnad = new SqlCommand(SPUPDateDepartment, getConnection); UPDateCommnad.CommandType = CommandType.StoredProcedure; UPDateCommnad.Parameters.AddWithValue("@DepartmentId", DepartmentID); UPDateCommnad.Parameters.AddWithValue("@DepartmentManager", AssignNewManagr); UPDateCommnad.Parameters.AddWithValue("@Active", AssignNewActive); UPDateCommnad.ExecuteNonQuery(); GridViewDepartment.EditIndex = -1; GetDepartmentList(); }
(GridView1.Rows[e.RowIndex].FindControl("DropDownListName") as DropDownList).SelectedItem ;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)