How to send check boxes ID in gridview in one string for mass update.

Posted by SmartDev on Stack Overflow See other posts from Stack Overflow or by SmartDev
Published on 2010-06-15T21:19:01Z Indexed on 2010/06/15 21:22 UTC
Read the original article Hit count: 272

Filed under:
|

hi ,

I have a grid which has check boxes and when selecting the top chek box select all will select all the check box in gridview and would update .for this im using for loop where it exceutes every time and this is taking lot of time cuase there are more thn 100 records in grid .

try { string StrOutputMessageDisplayDocReqCsu = string.Empty; string strid = string.Empty; string strflag = string.Empty; string strSelected = string.Empty;

        for (int j = 0; j < GdvDocReqMU.Rows.Count; j++)
        {
                        CheckBox Chkupdate = (CheckBox)GdvDocReqMU.Rows[j].Cells[1].FindControl("chkDR");
            if (Chkupdate != null)
            {
                if (Chkupdate.Checked)
                {
                    strid = ((Label)GdvDocReqMU.Rows[j].FindControl("lblIDDocReqCsu")).Text;
                    strflag = ((Label)GdvDocReqMU.Rows[j].FindControl("lblStatusDocReqCsu")).Text;                     
                    cmd = new SqlCommand("sp_Update_v1", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@id", strSelected);
                    cmd.Parameters.AddWithValue("@flag", DdlStatusDocReqMU.SelectedValue);
                    cmd.Parameters.AddWithValue("@notes", txtnotesDocReqMU.Text);
                    cmd.Parameters.AddWithValue("@user", strUseridDRAhk);
                    cmd.Parameters.Add(new SqlParameter("@message", SqlDbType.VarChar, 100, ParameterDirection.Output, false, 0, 50, "message", DataRowVersion.Default, null));
                    cmd.UpdatedRowSource = UpdateRowSource.OutputParameters;
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                }

            }
        }
        //}

        //StrOutputMessageDisplayDocReqCsu += (string)cmd.Parameters["@message"].Value + "<br/>";
        //lbldbmessDocReqAhk.Text += StrOutputMessageDisplayDocReqCsu + "<br>";
        GetgridDocReq();
     }
    catch (Exception ex)
    {
        lbldbmessDocReqAhk.Text = ex.Message.ToString();
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp