protected void btnDocsAdd_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); lblDocsErrorMsg.Text = ""; if (ViewState["DocsTable"] == null) { dt.Columns.Add("Nature of Document"); dt.Columns.Add("Sr. No. From"); dt.Columns.Add("Sr. No. To"); dt.Columns.Add("Total Number"); dt.Columns.Add("Cancelled"); } else { dt = (DataTable)ViewState["DocsTable"]; } DataRow dr = dt.NewRow(); dr["Nature of Document"] = ddlDocsNatureOfDoc.SelectedItem.Text.ToString(); dr["Sr. No. From"] = txtDocsSrNoFrom.Text.Trim(); dr["Sr. No. To"] = txtDocsSrNoTo.Text.Trim(); dr["Total Number"] = txtDocsTotalNo.Text.Trim(); dr["Cancelled"] = txtDocsCancelled.Text.Trim() == "" ? "0" : txtDocsCancelled.Text.Trim(); dt.Rows.Add(dr); ViewState["DocsTable"] = dt; GridDocs.DataSource = dt; GridDocs.DataBind(); ClearDocs(); }
protected void GridDocs_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteRecords") { DataTable DocsTable = (DataTable)ViewState["DocsTable"]; DocsTable.Rows.RemoveAt(int.Parse(e.CommandArgument.ToString())); ViewState["DocsTable"] = DocsTable; GridDocs.DataSource = DocsTable; GridDocs.DataBind(); } }
protected void clearGrid() // clear all grid or view state all tab data { grdB2B.DataSource = null; grdB2B.DataBind(); GridB2cl.DataSource = null; GridB2cl.DataBind(); GridB2cs.DataSource = null; GridB2cs.DataBind(); GridCdnr.DataSource = null; GridCdnr.DataBind(); GridCdnur.DataSource = null; GridCdnur.DataBind(); GridExp.DataSource = null; GridExp.DataBind(); GridAt.DataSource = null; GridAt.DataBind(); GridAtAdj.DataSource = null; GridAtAdj.DataBind(); GridHsn.DataSource = null; GridHsn.DataBind(); GridExeMp.DataSource = null; GridExeMp.DataBind(); GridDocs.DataSource = null; GridDocs.DataBind(); ViewState["B2BTable"] = null; ViewState["B2ClTable"] = null; ViewState["B2CSTable"] = null; ViewState["CDNRTable"] = null; ViewState["CDNURTable"] = null; ViewState["ExpTable"] = null; ViewState["AtTable"] = null; ViewState["AtAdjTable"] = null; ViewState["HsnTable"] = null; ViewState["ExeMpTable"] = null; ViewState["DocsTable"] = null; ClearB2B(); ClearB2cl(); ClearB2cs(); ClearCdnur(); ClearExp(); ClearAt(); ClearDocs(); ClearAtAdj(); ClearExeMp(); ClearHsn(); ClearCdnr(); }