Reload page or Refresh control values ,after submit in database

Analyst_SQL 3,551 Reputation points
2023-03-08T12:53:47.0733333+00:00

I have class,which is, i am calling into controller for Prdno get from database.

    public class RecordID
    {
        SqlConnection con = new SqlConnection("data source=SERVER1\\SQLEXPRESS;initial catalog=SilverProduction;integrated security=True;MultipleActiveResultSets=True;");


     

        public List<CascadingModel> GeneateBBID()
        {
            List<CascadingModel> item = new List<CascadingModel>();
            con.Open();
            SqlCommand cmd = new SqlCommand("SP_Generate_SB_ID", con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                var bbID = new CascadingModel();
                bbID.Prdno = int.Parse(rdr["Prdno"].ToString());

                item.Add(bbID);
            }
            con.Close();

            return item;
        }

Controller

  RecordID sdb = new RecordID();
        public ActionResult CreateBigBale()

        {

          
            var secID = 0;
            ViewBag.secID = new SelectList(DB.Sections.Where(bt => bt.SecID > secID), "SecID", "Secnam", "0");
            var codeItem = 0;
            ViewBag.codeItem = new SelectList(DB.ItemMasterFiles.Where(bt => bt.CodeItem > codeItem && bt.TiD==2  ), "Codeitem", "Descriptionitem", "0");
        

            var cID = 0;
            ViewBag.cID = new SelectList(DB.Catagories.Where(bt => bt.CID > cID), "CID", "CName", "0");


            var bigbaleMV = new CascadingModel();

            bigbaleMV.Prdnoa = sdb.GeneateBBID();

            bigbaleMV.Prdno = bigbaleMV.Prdnoa[0].Prdno;

            return View(bigbaleMV);

        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult CreateBigBale(CascadingModel bigbalemv)
        {
            var newbigbale = new Probale();
            newbigbale.Prdno = bigbalemv.Prdno;
            newbigbale.Codeitem = bigbalemv.CodeItem;
            newbigbale.SecID = bigbalemv.SecId;
            newbigbale.prdqty = 1;
            newbigbale.CID = bigbalemv.Cid;
            newbigbale.EntryDate = DateTime.Now;



            DB.Probales.Add(newbigbale);
            DB.SaveChanges();




            return Redirect("~/BBPV.aspx?Prdno=" + bigbalemv.Prdno);


        
        }

now ,i want ,when i insert record into database,then below code run again

 var bigbaleMV = new CascadingModel();



            bigbaleMV.Prdnoa = sdb.GeneateBBID();



            bigbaleMV.Prdno = bigbaleMV.Prdnoa[0].Prdno;


ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,263 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,268 questions
{count} votes