Esempio n. 1
0
        private void SetInitRow()
        {
            DataTable dt = new DataTable();
            DataRow   dr = null;

            dt.Columns.Add(new DataColumn("PARTICULARS", typeof(string)));
            dt.Columns.Add(new DataColumn("DEBIT", typeof(string)));
            dt.Columns.Add(new DataColumn("CREDIT", typeof(string)));
            dt.Columns.Add(new DataColumn("NARR", typeof(string)));
            dt.Columns.Add(new DataColumn("JVSNO", typeof(string)));

            dr = dt.NewRow();
            dr["PARTICULARS"] = string.Empty;
            dr["DEBIT"]       = string.Empty;
            dr["CREDIT"]      = string.Empty;
            dr["NARR"]        = string.Empty;
            dr["JVSNO"]       = string.Empty;

            dt.Rows.Add(dr);

            //Store the DataTable in ViewState
            ViewState["dt_adItm"] = dt;

            GVJV.DataSource = dt;
            GVJV.DataBind();
        }
Esempio n. 2
0
        private void AddNewRow()
        {
            int rowIndex = 0;

            if (ViewState["dt_adItm"] != null)
            {
                DataTable dt    = (DataTable)ViewState["dt_adItm"];
                DataRow   drRow = null;
                if (dt.Rows.Count > 0)
                {
                    for (int i = 1; i <= dt.Rows.Count; i++)
                    {
                        //extract the Controls values
                        DropDownList DDLPar  = (DropDownList)GVJV.Rows[rowIndex].Cells[0].FindControl("DDL_Par");
                        TextBox      TBDbt   = (TextBox)GVJV.Rows[rowIndex].Cells[1].FindControl("TBDbt");
                        TextBox      TBCrd   = (TextBox)GVJV.Rows[rowIndex].Cells[2].FindControl("TBCrd");
                        TextBox      TBnarr  = (TextBox)GVJV.Rows[rowIndex].Cells[3].FindControl("TBnarr");
                        HiddenField  HFJVSNO = (HiddenField)GVJV.Rows[rowIndex].Cells[4].FindControl("HF_JVSNo");

                        drRow = dt.NewRow();

                        dt.Rows[i - 1]["PARTICULARS"] = DDLPar.Text;
                        dt.Rows[i - 1]["DEBIT"]       = TBDbt.Text;
                        dt.Rows[i - 1]["CREDIT"]      = TBCrd.Text;
                        dt.Rows[i - 1]["NARR"]        = TBnarr.Text;
                        dt.Rows[i - 1]["JVSNo"]       = HFJVSNO.Value;

                        rowIndex++;

                        DDLPar.Focus();
                    }
                    dt.Rows.Add(drRow);
                    ViewState["dt_adItm"] = dt;

                    GVJV.DataSource = dt;
                    GVJV.DataBind();
                }
            }
            else
            {
                Response.Write("ViewState is null");
            }

            //Set Previous Data on Postbacks
            SetPreRow();
        }
Esempio n. 3
0
        protected void GVJV_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (ViewState["dt_adItm"] != null)
            {
                DataTable dt           = (DataTable)ViewState["dt_adItm"];
                DataRow   drCurrentRow = null;
                int       rowIndex     = Convert.ToInt32(e.RowIndex);
                if (dt.Rows.Count > 1)
                {
                    dt.Rows.Remove(dt.Rows[rowIndex]);
                    drCurrentRow          = dt.NewRow();
                    ViewState["dt_adItm"] = dt;

                    GVJV.DataSource = dt;
                    GVJV.DataBind();

                    SetPreRow();
                    //ptnSno();
                }
            }
        }