Beispiel #1
0
        protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int SR_NO = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);

            using (OnlineAdmissionNews entities = new OnlineAdmissionNews())
            {
                NEWS news = (from c in entities.NEWS
                             where c.SR_NO == SR_NO
                             select c).FirstOrDefault();
                if (news != null)
                {
                    entities.NEWS.Remove(news);
                    entities.SaveChanges();
                }
            }
            this.BindGrid();
        }
Beispiel #2
0
        protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row   = GridView1.Rows[e.RowIndex];
            int         SR_NO = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);
            string      DATA  = (row.FindControl("txtDATA") as TextBox).Text;

            using (OnlineAdmissionNews entities = new OnlineAdmissionNews())
            {
                NEWS news = (from c in entities.NEWS
                             where c.SR_NO == SR_NO
                             select c).FirstOrDefault();
                news.DATA = DATA;
                entities.SaveChanges();
            }
            GridView1.EditIndex = -1;
            this.BindGrid();
        }
Beispiel #3
0
 protected void Insert(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(Convert.ToString(txtNewDATA.Text)))
     {
         using (OnlineAdmissionNews entities = new OnlineAdmissionNews())
         {
             NEWS news = (from c in entities.NEWS
                          where c.DATA == txtNewDATA.Text
                          select c).FirstOrDefault();
             if (news == null)
             {
                 NEWS Insert = new NEWS
                 {
                     DATA = txtNewDATA.Text
                 };
                 entities.NEWS.Add(Insert);
                 entities.SaveChanges();
             }
             txtNewDATA.Text = string.Empty;
         }
         this.BindGrid();
     }
 }