protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bal.Comments obj = new bal.Comments(); if (Request.QueryString["commentid"] == null) { GridView1.DataSource = obj.list(); GridView1.DataBind(); } else { obj.commentid = Int32.Parse(Request.QueryString["commentid"].ToString()); if (obj.remove() > 0) { Response.Redirect("~/admin/commentslist.aspx"); } else { Response.Write("Data couldnot Removed !!"); } } } }
public int save(bal.Comments o) { sqlcmd = con.dbCommand("comments_save"); sqlcmd.Parameters.AddWithValue("@commentid", o.commentid); sqlcmd.Parameters.AddWithValue("@commentby", o.commentby); sqlcmd.Parameters.AddWithValue("@comments", o.comments); sqlcmd.Parameters.AddWithValue("@recipeid", o.recipeid); return(sqlcmd.ExecuteNonQuery()); }
void dList(DataTable dt) { for (int i = 0; i < dt.Rows.Count; i++) { bal.Comments c = new bal.Comments(); c.commentid = Int32.Parse(dt.Rows[i]["commentid"].ToString()); c.commentby = dt.Rows[i]["commentby"].ToString(); c.comments = dt.Rows[i]["comments"].ToString(); cList.Add(c); } }
public List <bal.Comments> get(bal.Comments o) { sqlcmd = con.dbCommand("comments_get"); sqlcmd.Parameters.AddWithValue("@commentid", o.commentid); SqlDataReader sqldr = sqlcmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(sqldr); dList(dt); return(cList); }
public int remove(bal.Comments o) { sqlcmd = con.dbCommand("comments_remove"); sqlcmd.Parameters.AddWithValue("@commentid", o.commentid); return(sqlcmd.ExecuteNonQuery()); }