You must Sign In to post a response.
  • Category: Windows

    How yo add new row for data grid view and updated same id in c# windows application

    I am creating windows application using c# 2010, here i am using data grid view for billing purpose, once i am stored the values to database, and then after some time i am retrieve my first bill values and i am doing some changes and update the records for same bill number. Here i am not using text boxes i want update only my date grid view.

    How to write update query any one give me ideas.
  • #767394

    You can use Gridview RowEditing event for edit the records and for update the modified content into database you can use RowUpdating event, please refer below sample code for your reference.

    protected void GV_RowEditing(object sender, GridViewEditEventArgs e)
    GV.EditIndex = e.NewEditIndex;
    protected void GV_RowUpdating(object sender, GridViewUpdateEventArgs e)
    int EmpNo = Convert.ToInt32(GV.Rows[e.RowIndex].Cells[0].Text);
    TextBox EName = (TextBox)GV.Rows[e.RowIndex].Cells[1].Controls[0];
    TextBox Job = (TextBox)GV.Rows[e.RowIndex].Cells[2].Controls[0];
    TextBox Mgr = (TextBox)GV.Rows[e.RowIndex].Cells[3].Controls[0];
    //In edit mode also we give fileupload to upload new image and save that while update the row infomration.

    cmd = new SqlCommand("Update_Employee_Details", con);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@EMPNO", EmpNo);
    cmd.Parameters.AddWithValue("@Ename", EName.Text);
    cmd.Parameters.AddWithValue("@Job", Job.Text);

    GV.EditIndex = -1;
    catch (Exception ex)

    Hope this will helpful to you..

    Refer below link for more details,

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #767425
    Sir this is not web application, this is for windows application.

    Give me some ideas.

  • Sign In to post your comments