<div class="successbox" id="successbox" runat="server"> <div class="x3"></div> <p class="success">روزنوشته مورد نظر با موفقیت حذف شد و به زباله دان انتقال یافت.</p> </div> <div class="managementlist"> <p>لیست روزنوشته های ثبت موقت</p> <asp:GridView ID="content" runat="server" AllowPaging="True" AutoGenerateColumns="False" OnPageIndexChanging="OnPaging" PageSize="12" OnRowCommand="content_RowCommand"> <Columns> <asp:BoundField DataField="id" HeaderText="کد" ReadOnly="True" /> <asp:BoundField DataField="title" HeaderText="عنوان روزنوشته" /> <asp:BoundField DataField="datereg" HeaderText="تاریخ درج" /> <asp:BoundField DataField="dateupdate" HeaderText="تاریخ آخرین بروزرسانی" /> <asp:ButtonField HeaderText="حذف" CommandName="Delete" Text="حذف" ItemStyle-CssClass="deleteLink" /> <asp:ButtonField HeaderText="ویرایش" CommandName="Edit" Text="ویرایش" /> </Columns> </asp:GridView> </div>
private void BindGrid() { DAL run = new DAL(); DataTable dt = new DataTable(); string sqlText = "select * from tbl_content where notactive='true' and bin='false'"; dt = run.ExecuteQuery(sqlText); content.DataSource = dt; content.DataBind(); } protected void OnPaging(object sender, GridViewPageEventArgs e) { content.PageIndex = e.NewPageIndex; content.DataBind(); } protected void content_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { int row = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(content.Rows[row].Cells[0].Text); string st = string.Format("update tbl_content set bin='true' where id={0} ", id); DAL d1 = new DAL(); d1.ExecNonQuery(st); successbox.Style.Add("display", "block"); BindGrid(); } else { int row = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(content.Rows[row].Cells[0].Text); Response.Redirect(string.Format("panel.aspx?id={0}&contentid={1}", 56, id)); } }
ویرایش به درستی کار میکنه و مشکلی نداره.
زمانی که روی حذف میزنم سطر رو آپدیت میکنه اما به جای اینکه این خط کد رو اجرا کنه:
successbox.Style.Add("display", "block");
این ارور رو میده:
تاکید : سطر آپدیت میشه، فقط به جای نمایش پیغام موفقیت، این ارور رو میده!
مشکلش الان یه چیز دیگه هست :|
<div class="successbox" id="successbox" runat="server"> <div class="x3"></div> <p class="success">روزنوشته مورد نظر با موفقیت حذف شد و به زباله دان انتقال یافت.</p> </div> <div class="managementlist"> <p>لیست روزنوشته های قبلی</p> <asp:GridView ID="content" runat="server" AllowPaging="True" AutoGenerateColumns="False" OnPageIndexChanging="OnPaging" PageSize="12"> <Columns> <asp:BoundField DataField="id" HeaderText="کد" ReadOnly="True" /> <asp:HyperLinkField HeaderText="عنوان روزنوشته" Target="_blank" DataTextField="title" DataNavigateUrlFormatString="~/FullContent.aspx?id={0}" DataNavigateUrlFields="id " /> <asp:BoundField DataField="datereg" HeaderText="تاریخ درج" /> <asp:BoundField DataField="dateupdate" HeaderText="تاریخ آخرین بروزرسانی" /> <asp:ButtonField HeaderText="حذف" CommandName="Delete" Text="حذف" ItemStyle-CssClass="deleteLink" /> <asp:ButtonField HeaderText="ویرایش" CommandName="Edit" Text="ویرایش" /> </Columns> </asp:GridView> </div>
private void BindGrid() { DAL run = new DAL(); DataTable dt = new DataTable(); string sqlText = "select * from tbl_content where notactive='false' and bin='false'"; dt = run.ExecuteQuery(sqlText); content.DataSource = dt; content.DataBind(); } protected void OnPaging(object sender, GridViewPageEventArgs e) { content.PageIndex = e.NewPageIndex; content.DataBind(); } protected void content_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteItem") { int row = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(content.Rows[row].Cells[0].Text); string st = string.Format("update tbl_content set bin='{0}' where id={1} ", true, id); DAL d1 = new DAL(); d1.ExecNonQuery(st); successbox.Style.Add("display", "block"); BindGrid(); } else { int row = Convert.ToInt32(e.CommandArgument); int id = Convert.ToInt32(content.Rows[row].Cells[0].Text); Response.Redirect(string.Format("panel.aspx?id={0}&contentid={1}", 56, id)); } }
حذف رو که میزنم باید فیلد bin رو در دیتابیس از false به true آپدیت کنه اما ارور زیر رو میده.
ویرایش رو هم که میزنم همین زیر رو میده:
مشکل از کجاست؟
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)