Пример #1
0
    protected void addComment(object sender, EventArgs e)
    {
        Button btn = (Button)sender;

        GridViewRow row = (GridViewRow)btn.NamingContainer;

        DataControlFieldCell Datafld = (DataControlFieldCell)row.Controls[0];

        Label lbl = (Label)Datafld.Controls[1];

        TextBox txtB = (TextBox)Datafld.Controls[3];

        String stroka;

        stroka = txtB.Text;

        if (stroka.Trim().Length<1)
            return;

        System.Text.StringBuilder sb2 = new System.Text.StringBuilder(
                  HttpUtility.HtmlEncode(stroka));

        string commm;
        commm = sb2.ToString();
        commm = Regex.Replace(commm, "\\n", "<br />", RegexOptions.IgnoreCase);

        int commmID;
        commmID = Convert.ToInt16(lbl.Text);

        blogpostsModel.blogdbEntities bl = new blogpostsModel.blogdbEntities();
        blogpostsModel.blogcomment po = new blogpostsModel.blogcomment();
        po.commentID =commmID;
        po.commentMsgText = commm;
        bl.AddToblogcomments(po);
        bl.SaveChanges();

        Response.Redirect(Request.Path);
    }
Пример #2
0
 /// <summary>
 /// Create a new blogcomment object.
 /// </summary>
 /// <param name="cID">Initial value of the cID property.</param>
 /// <param name="commentID">Initial value of the commentID property.</param>
 public static blogcomment Createblogcomment(global::System.Int32 cID, global::System.Int32 commentID)
 {
     blogcomment blogcomment = new blogcomment();
     blogcomment.cID = cID;
     blogcomment.commentID = commentID;
     return blogcomment;
 }
Пример #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the blogcomments EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToblogcomments(blogcomment blogcomment)
 {
     base.AddObject("blogcomments", blogcomment);
 }
Пример #4
0
    protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "RemoveRecord")
        {

        string lbltext;
            try
            {
                int index = Convert.ToInt32(e.CommandArgument);
                GridView gr = sender as GridView;
                GridViewRow row = gr.Rows[index];

               Label lbl = row.FindControl("cID") as Label;
                lbltext = lbl.Text.Trim();
            }
            catch {
                return;
            }

            blogpostsModel.blogdbEntities bl = new blogpostsModel.blogdbEntities();

            blogpostsModel.blogcomment bc = new blogpostsModel.blogcomment();

            // remove using command
            string qStr = "Delete FROM blogcomments where cID="+lbltext;
            bl.ExecuteStoreCommand(qStr);
            bl.SaveChanges();

            Response.Redirect(Request.Path);

        }
    }