Пример #1
0
    private void LoadGrid()
    {
        try
        {
            BLItem objBL = new BLItem();                                                   // declare and initialize BLItem object
            Studentinfo.DataSource = objBL.GetStudent_Personal(Session["New"].ToString()); //setting data source for the gridview
            Studentinfo.DataBind();                                                        //bind the data source to the gridview
            Studentinfo.HeaderRow.Visible = false;
            Studentinfo.BorderStyle       = BorderStyle.None;

            for (int i = 0; i < Studentinfo.Rows.Count; i++)
            {
                Studentinfo.Rows[i].Cells[1].BorderStyle = BorderStyle.None;
                Studentinfo.Rows[i].Cells[1].ForeColor   = Color.White;
                Studentinfo.Rows[i].Cells[1].Font.Bold   = false;
            }
            for (int i = 0; i < Studentinfo.Rows.Count; i++)
            {
                Studentinfo.Rows[i].BorderStyle          = BorderStyle.None;
                Studentinfo.Rows[i].Cells[0].BorderStyle = BorderStyle.None;
                Studentinfo.Rows[i].Cells[0].ForeColor   = Color.Khaki;
                Studentinfo.Rows[i].Cells[0].Font.Bold   = true;
            }
        }
        catch (SqlException)
        {
            throw;
        }
    }
Пример #2
0
        public IActionResult Post([FromBody] MyStudent st)
        {
            Studentinfo s = new Studentinfo();

            s.Id         = st.Id;
            s.Name       = st.Name;
            s.Fathername = st.Fathername;
            s.Email      = st.Email;
            s.Phone      = st.Phone;

            _context.Studentinfo.Add(s);
            _context.SaveChanges();
            return(NoContent());
        }
Пример #3
0
        public IActionResult Deleteitem(int id)
        {
            MyStudent s1 = (from st in _context.Studentinfo
                            where id == st.Id
                            select new MyStudent
            {
                Id = st.Id,
                Name = st.Name,
                Fathername = st.Fathername,
                Email = st.Email,
                Phone = st.Phone
            }).First();
            Studentinfo s = new Studentinfo();

            s.Id         = s1.Id;
            s.Name       = s1.Name;
            s.Fathername = s1.Fathername;
            s.Email      = s1.Email;
            s.Phone      = s1.Phone;
            _context.Studentinfo.Attach(s);
            _context.Studentinfo.Remove(s);
            _context.SaveChanges();
            return(Ok(s));
        }