Click here to Skip to main content
15,922,007 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following code, when user clicks update, a value will be inserted to the time out column.

at default, timeout value is null .

so when the row is updated, how do I change the column of the row?

C#
Label lblEditEmpName = (Label)EMPLOYEERECORD.Rows[e.RowIndex].FindControl("lblEditEmpName");
           Label lblEditTimeOut = (Label)EMPLOYEERECORD.Rows[e.RowIndex].FindControl("lblEditTimeOut");


           DatabaseModule.SQcon.Open();
           string cmdstr = "update dbo.RecordEmployee set TIME_OUT=@timeout where    EMPLOYEE_NAME =@empname";
           SqlCommand cmd = new SqlCommand(cmdstr, DatabaseModule.SQcon);

           cmd.Parameters.AddWithValue("@empname", lblEditEmpName.Text);
           cmd.Parameters.AddWithValue("@timeout", DateTime.Now.ToString("T"));

           cmd.ExecuteNonQuery();
           DatabaseModule.SQcon.Close();
           EMPLOYEERECORD.EditIndex = -1;

           BindData();
Posted

Try this:

C#
DataGridView row = EMPLOYEERECORD.Rows[e.RowIndex];
row.DefaultCellStyle.BackColor = Color.Green;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900