Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int idCat  = Convert.ToInt32(Request["idcat"]);
                int idPost = Convert.ToInt32(Request["id"]);

                rpBreadcrumb.DataSource = data.Cat_SelectID(idCat);
                rpBreadcrumb.DataBind();

                rpContent.DataSource = data.Post_SelectID(idPost);
                rpContent.DataBind();

                rpPostsRandom.DataSource = data.Post_SelectRandom(idCat);
                rpPostsRandom.DataBind();

                var titlePost = data.Post_SelectID(idPost);

                foreach (var t in titlePost)
                {
                    Session["title"] = t.Post_title.ToString();
                }
            }
        }
Example #2
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int index = Convert.ToInt32(e.CommandArgument);

            // Chi tiet
            if (e.CommandName.Equals("detail"))
            {
                int ID = Convert.ToInt32(GridView1.DataKeys[index].Value.ToString());
                DetailsView1.DataSource = data.Post_SelectID(ID);
                DetailsView1.DataBind();
                StringBuilder sb = new StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$(document).ready(function(){$('#detailModal').modal('show');});");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "DetailModalScript", sb.ToString(), false);
            }

            // Sua bai viet
            if (e.CommandName.Equals("edit"))
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$(document).ready(function(){$('#editModal').modal('show');});");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditModalScript", sb.ToString(), false);
            }

            // Xoa bai viet
            if (e.CommandName.Equals("delete"))
            {
                string code = GridView1.DataKeys[index].Value.ToString();
                HfDeleteID.Value = code;
                StringBuilder sb = new StringBuilder();
                sb.Append(@"<script type='text/javascript'>");
                sb.Append("$(document).ready(function(){$('#deleteModal').modal('show');});");
                sb.Append(@"</script>");
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "DeleteModalScript", sb.ToString(), false);
            }
        }