private void AddNewRow() { int rowIndex = 0; GridViewRow gvrow = grvStudentDetails.BottomPagerRow; 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 TextAmount = (TextBox)grvStudentDetails.Rows[rowIndex].Cells[1].FindControl("txtamount"); DropDownList dblmode = (DropDownList)grvStudentDetails.Rows[rowIndex].Cells[5].FindControl("dblmode"); TextBox TextBank = (TextBox)grvStudentDetails.Rows[rowIndex].Cells[2].FindControl("txtbank"); TextBox TextBranch = (TextBox)grvStudentDetails.Rows[rowIndex].Cells[3].FindControl("txtbranch"); TextBox TextCheque = (TextBox)grvStudentDetails.Rows[rowIndex].Cells[3].FindControl("txtcheque"); RadioButtonList RBLStatus = (RadioButtonList)grvStudentDetails.Rows[rowIndex].Cells[4].FindControl("rblstatus"); drCurrentRow = dtCurrentTable.NewRow(); drCurrentRow["RowNumber"] = i + 1; dtCurrentTable.Rows[i - 1]["Col1"] = TextAmount.Text; dtCurrentTable.Rows[i - 1]["Col2"] = dblmode.SelectedValue; dtCurrentTable.Rows[i - 1]["Col3"] = TextBank.Text; dtCurrentTable.Rows[i - 1]["Col4"] = TextBranch.Text; dtCurrentTable.Rows[i - 1]["Col5"] = TextCheque.Text; dtCurrentTable.Rows[i - 1]["Col6"] = RBLStatus.SelectedValue; rowIndex++; } dtCurrentTable.Rows.Add(drCurrentRow); ViewState["CurrentTable"] = dtCurrentTable; grvStudentDetails.DataSource = dtCurrentTable; grvStudentDetails.DataBind(); TextBox txn = (TextBox)grvStudentDetails.Rows[rowIndex].Cells[1].FindControl("txtamount"); txn.Focus(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)