private void AddNewRow()
{
int rowIndex = 0;
if (ViewState["CurrentTable"] != null)
{
DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
DataRow drCurrentRow = null;
if (dtCurrentTable.Rows.Count > 0)
{
for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
{
TextBox TextBoxItem =
(TextBox)gvCheckList.Rows[rowIndex].Cells[1].FindControl("txtItem");
TextBox TextBoxSspSpec =
(TextBox)gvCheckList.Rows[rowIndex].Cells[2].FindControl("txtSspspec");
drCurrentRow = dtCurrentTable.NewRow();
drCurrentRow["RowNumber"] = i + 1;
dtCurrentTable.Rows[i - 1]["Col1"] = TextBoxItem.Text;
dtCurrentTable.Rows[i - 1]["Col2"] = TextBoxSspSpec.Text;
rowIndex++;
}
dtCurrentTable.Rows.Add(drCurrentRow);
ViewState["CurrentTable"] = dtCurrentTable;
gvCheckList.DataSource = dtCurrentTable;
gvCheckList.DataBind();
}
}
else
{
Response.Write("ViewState is null");
}
SetPreviousData();
}
for example i have 6 rows in a gridview in tat every rows having a insertbutton named new. If i Click tat Button i want a new row, below the existing one... but here am getting a new row below the grid view