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
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
Iftikar HussainPosted Aug 27, 2013, 11:41 AM
Praveen MathiPosted Aug 27, 2013, 8:28 AM
Iftikar HussainPosted Aug 27, 2013, 8:13 AM
Praveen MathiPosted Aug 27, 2013, 7:51 AM
am called here,
protected void gvCheckList_RowCommand(object sender, GridViewCommandEventArgs e)
hai Iftikar,
gvchecklist is my gridview name,
As u told i did all things but still am not getting correct output... it shows error only.
Iftikar HussainPosted Aug 27, 2013, 7:37 AM
From where you are calling AddNewRow()