protected void Btnsave_Click(object sender, EventArgs e) { string c = "Insert into Notification(msg,ndt) values('" + TxtNotification.Text + "','" + DateTime.Now.ToString() + "')"; DBManager dm = new DBManager(); bool x = dm.ExecuteMyInsertUpdateOrDelete(c); GVNotification.DataBind(); TxtNotification.Text = ""; if (x == true) { Response.Write("<script>alert('Notificatiomn Saved.');</script>"); } else { Response.Write("<script>alert('Notification not saved.');</script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack == false) { ConnectionManager cm = new ConnectionManager(); cm.YourCommand = "SELECT top 5 message from Tbl_Notification order by notification_ID desc"; GVNotification.DataSource = cm.ExecuteSelectByDisconnected(); GVNotification.DataBind(); int i = 0; foreach (GridViewRow r in GVNotification.Rows) { if (i != 0) { Image im = (Image)r.FindControl("ImgNew"); im.Visible = false; } i++; } } }