moving the new row to the bottom
-
i need to move the new row to be at the bottom and here's the code.. SqlConnection con = new SqlConnection(connectionstring); SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM BaselAnfouqa_Clients", con); try { DataTable dtBasel = new DataTable(); adp.Fill(dtBasel); DataRow drRow = dtBasel.NewRow(); dtBasel.Rows.InsertAt(drRow,0); gvtest.EditIndex = 0; gvtest.DataSource = dtBasel; gvtest.DataBind(); ((LinkButton)gvtest.Rows[1].Cells[0].Controls[0]).Text = ("Insert"); dtBasel.Clear(); } catch { } finally { con.Close(); }
-
i need to move the new row to be at the bottom and here's the code.. SqlConnection con = new SqlConnection(connectionstring); SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM BaselAnfouqa_Clients", con); try { DataTable dtBasel = new DataTable(); adp.Fill(dtBasel); DataRow drRow = dtBasel.NewRow(); dtBasel.Rows.InsertAt(drRow,0); gvtest.EditIndex = 0; gvtest.DataSource = dtBasel; gvtest.DataBind(); ((LinkButton)gvtest.Rows[1].Cells[0].Controls[0]).Text = ("Insert"); dtBasel.Clear(); } catch { } finally { con.Close(); }
-
by taking the rowcount of the data table. and using the code dtBasel.Rows.Insertat(Newrow,Rowcount+1); This may help you..
forgive me but am new at this ..... i tried but an error happend (the name 'rowcount' doesnot exist in the current context) what should i do?
-
forgive me but am new at this ..... i tried but an error happend (the name 'rowcount' doesnot exist in the current context) what should i do?
you haven't declared 'rowcount'. Try this : int rowcount = dtBasel.Rows.Count + 1; dtBasel.Rows.Insertat(Newrow,rowcount);