示例#1
0
        // The id parameter should match the DataKeyNames value set on the control
        // or be decorated with a value provider attribute, e.g. [QueryString]int id

        public Assignment1.Models.Comment FVComment_GetItem([QueryString] int?id)
        {
            Models.Comment item = null;
            if (id.HasValue)
            {
                item = db.Comments
                       .Where(c => c.ID == id.Value)
                       .Select(c => c)
                       .FirstOrDefault();
            }
            return(item);
        }
示例#2
0
        public void FVComment_InsertItem()
        {
            var item = new Assignment1.Models.Comment();

            TryUpdateModel(item);
            if (ModelState.IsValid)
            {
                // Save changes here
                item.ID = Convert.ToInt32(Request.QueryString["ID"]);
                db.Comments.Add(item);
                db.SaveChanges();
            }
        }