mahesh waghela

mahesh waghela

  • NA
  • 93
  • 114k

Edit On DataBound Datagridview

Sep 10 2011 6:53 AM

I have Populate Datagridview by Follow:

            string constr = "server=.;initial catalog=Database;uid=uid;pwd=pwd";

            SqlConnection con = new SqlConnection(constr);

            con.Open();

 

            string sql = " select srno,description,pcs,carat,rate,amount from invcarat where " +

                       " invno= ('" + textBox1.Text + "') and companyID=('" + label1.Text + "')";

            SqlCommand cmd = new SqlCommand(sql, con);

            SqlDataAdapter dap = new SqlDataAdapter(cmd);

            mydataset = new DataSet();

            dap.Fill(mydataset);

            bindingsource1 = new BindingSource();

            bindingsource1.DataSource = mydataset;

            bindingsource1.DataMember = mydataset.Tables[0].TableName;

            newdgv.DataSource = bindingsource1;

 

It works fine and display all the data but problem is that it not allow me to edit directly.

Suppose If I want to edit srno columns first row than it wan't allow and when I move to down row and then again come to same row than it allow me to edit.

Why it not allow me to edit directly. Why I have to move to down row and come againt same row to edit?. 


Answers (3)