Gridview in asp.net 2.0
-
Hi, I am working on gridview. while deleting the record i am getting the error as Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index my code is protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int empid=0; empid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } please give me what is the syntax for it. can any one help me urgently thanks!
-
Hi, I am working on gridview. while deleting the record i am getting the error as Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index my code is protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int empid=0; empid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } please give me what is the syntax for it. can any one help me urgently thanks!
Hi change ur rowindex value or empid value after that u will get other wise reply to me i will give code for u .. Reg Nantha
-
Hi change ur rowindex value or empid value after that u will get other wise reply to me i will give code for u .. Reg Nantha
Hi, Set e.EditEndex=-1 After deleting the row.
Naresh Patel
-
Hi change ur rowindex value or empid value after that u will get other wise reply to me i will give code for u .. Reg Nantha
thanks your guidance.:rose: can u send me code please
-
thanks your guidance.:rose: can u send me code please
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int empid=0; empid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); e.EditIndex=-1; }
Naresh Patel
-
Hi, I am working on gridview. while deleting the record i am getting the error as Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index my code is protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int empid=0; empid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } please give me what is the syntax for it. can any one help me urgently thanks!
Hi try this ... protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int n = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); int empid=n-1; cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } in case not working send full functionality about this grid view process
-
Hi try this ... protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int n = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); int empid=n-1; cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } in case not working send full functionality about this grid view process
I am giving you only Idea, not implementation. Ok
Naresh Patel
-
I am giving you only Idea, not implementation. Ok
Naresh Patel
very thank you Naresh Patel