2
Reply

how to get the edit mode in c# dot net datagridview

kannan T

kannan T

15y
7.9k
0
Reply

      To get edit mode in c# .net datagridview write the following code.

         protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView1.EditIndex = e.NewEditIndex;
            bindgrid();
        }

    void bindgrid()
        {
            cn = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString);
            cn.Open();
            SqlCommand cmd = new SqlCommand("select * from stud", cn); // stud is a table name.
            SqlDataReader dr = cmd.ExecuteReader();
            GridView1.DataSource = dr;
            GridView1.DataBind();
        }