Example #1
0
        // GET: Form
        public ActionResult FORM()
        {
            //FORMmodel fm = new FORMmodel();

            //fm.DDMobileBrand.Add(new SelectListItem { Text = "a", Value = "av" });
            //fm.DDMobileBrand.Add(new SelectListItem { Text = "b", Value = "bv" });

            //List<SelectListItem> DDMobileBrand = new List<SelectListItem>();
            //DDMobileBrand.Add(new SelectListItem { Text = "a", Value = "av" });
            //DDMobileBrand.Add(new SelectListItem { Text = "b", Value = "bv" });

            //SelectListItem DDMobileBrandsl = new SelectListItem();
            //DDMobileBrandsl.Text = "a";
            //DDMobileBrandsl.Value = "av";;

            //fm.DDMobileBrand.Add(new SelectListItem { Text = "a", Value = "av" });
            //===================================

            //fm.CHKMobileBrandlist.Add(new CHKMobileBrandModel { id=1, name="chk1", @checked=true});
            //fm.CHKMobileBrandlist.Add(new CHKMobileBrandModel { id = 2, name = "chk2", @checked = true });

            //===================

            FORMmodel     fmm  = new FORMmodel();
            var           list = new List <CHKMobileBrandModel>();
            SqlConnection cn   = new SqlConnection("Data Source=IKW-PC;Initial Catalog=VASTest;Integrated Security=True");

            cn.Open();
            using (SqlCommand cmd = new SqlCommand("select chkid,chkname,chkchecked FROM MVCchkMobileBrands", cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        list.Add(new CHKMobileBrandModel {
                            id = rdr.GetInt32(0), name = rdr.GetString(1), @checked = rdr.GetBoolean(2)
                        });
                    }
                    fmm.DDMobilBrandDB = new SelectList(list, "ID", "Name");// list;
                }
            }
            cn.Close();
            //list.Add(new CHKMobileBrandModel { id = 1, name = "A" });
            //list.Add(new CHKMobileBrandModel { id = 2, name = "B" });
            //fmm.DDMobilBrandDB = new SelectList(list);

            return(View(fmm));

            //return View();
        }
Example #2
0
        public ActionResult Form(FORMmodel fm)
        {
            // bool a, b, c;
            // List<int> l = new List<int>();
            // arr

            //foreach (CHKMobileBrandModel ch in fm.CHKMobileBrandlist)
            // {
            //     if (ch.@checked = true )

            //if (ch.id.Equals(1))
            //{ a = true; }
            //    else if(ch.id.Equals(2))
            //{ b = true; }
            //    else
            //{ c = true; }

            //l.Add(c.id);
            //}
            //XmlSerializer x=new XmlSerializer().Serialize()
            //byte[] postBytes = Encoding.UTF8.GetBytes()

            return(View(fm));
        }