S
shavi g
Guest
protected void GridViewEmployeees_SelectedIndexChanged(object sender, EventArgs e)
{
BindData();
}
private void BindData()
{
//obtain the index of the selected row
int selectedIndexRow = GridViewEmployeees.SelectedIndex;
//read the Employee ID
int employeeID = (int)GridViewEmployeees.DataKeys[selectedIndexRow].Value;
//define data objects and
string connectionString = ConfigurationManager.ConnectionStrings["Dorknozzle"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("SelectEmployeesForDataListControl", connection);
command.Parameters.Add("EmployeeID", SqlDbType.Int);
command.Parameters["EmployeeID"].Value = employeeID;
try
{
connection.Open();
command.CommandType = CommandType.StoredProcedure;
command.ExecuteNonQuery();
SqlDataReader reader = command.ExecuteReader();
DetailsEmployee.DataSource = reader;
DetailsEmployee.DataKeyNames = new string[] { "EmployeeID" };
DetailsEmployee.DataBind();
}
finally
{
connection.Close();
}
}
{
BindData();
}
private void BindData()
{
//obtain the index of the selected row
int selectedIndexRow = GridViewEmployeees.SelectedIndex;
//read the Employee ID
int employeeID = (int)GridViewEmployeees.DataKeys[selectedIndexRow].Value;
//define data objects and
string connectionString = ConfigurationManager.ConnectionStrings["Dorknozzle"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("SelectEmployeesForDataListControl", connection);
command.Parameters.Add("EmployeeID", SqlDbType.Int);
command.Parameters["EmployeeID"].Value = employeeID;
try
{
connection.Open();
command.CommandType = CommandType.StoredProcedure;
command.ExecuteNonQuery();
SqlDataReader reader = command.ExecuteReader();
DetailsEmployee.DataSource = reader;
DetailsEmployee.DataKeyNames = new string[] { "EmployeeID" };
DetailsEmployee.DataBind();
}
finally
{
connection.Close();
}
}