FineUI 官方论坛

标题: 关于grid不能刷新的问题求助! [打印本页]

作者: 老李    时间: 2013-8-13 00:19
标题: 关于grid不能刷新的问题求助!
请先看代码
WebForm1.aspx:

  1. <P> <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="DepotWeb.WebForm1" %></P>
  2. <P><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</A>"></P>
  3. <P><html xmlns="<A href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>">
  4. <head runat="server">
  5.     <title></title>
  6. </head>
  7. <body>
  8.     <form id="form1" runat="server">
  9.     <ext:PageManager ID="PageManager1" runat="server" AutoSizePanelID="Grid1" />
  10.     <ext:Grid ID="Grid1" runat="server" EnableCheckBoxSelect="true"
  11.         EnableRowNumber="true" AutoHeight="true"
  12.         Title="操作员管理" DataKeyNames="GroupID" Icon="Table">
  13.         <Toolbars>
  14.         <ext:Toolbar ID="Toolbar1" runat="server">
  15.             <items>
  16.             <ext:Button ID="btnDel" Text="删除选中项" runat="server" Icon="Delete" ConfirmText="确定要删除这些记录吗?"></ext:Button>
  17.             </items>
  18.         </ext:Toolbar>
  19.         </Toolbars>
  20.         <Columns>
  21.         <ext:BoundField DataField="GroupID" HeaderText="编号" Width="50px" />
  22.         <ext:BoundField DataField="GroupName" HeaderText="角色名称" Width="150px" />
  23.         <ext:BoundField DataField="GroupMs" HeaderText="描述" Width="180px" />
  24.         </Columns>
  25.     </ext:Grid>
  26.     </form>
  27. </body>
  28. </html>
  29. </P>
复制代码
WebForm1.aspx.cs
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using BLL;
  8. using Entity;

  9. namespace DepotWeb
  10. {
  11. public partial class WebForm1 : System.Web.UI.Page
  12. {
  13. private SystemGroupBLL _sgb = new SystemGroupBLL();
  14. private List<Entity.SystemGroup> _ls = null;
  15. protected void Page_Load(object sender, EventArgs e)
  16. {
  17. btnDel.OnClientClick = Grid1.GetNoSelectionAlertReference("至少选择一项!");
  18. btnDel.Click += new EventHandler(btnDel_Click);
  19. if (!Page.IsPostBack)
  20. {
  21. Bind();
  22. }
  23. }

  24. void btnDel_Click(object sender, EventArgs e)
  25. {
  26. foreach (int row in Grid1.SelectedRowIndexArray)
  27. {
  28. _sgb.Del(int.Parse(Grid1.DataKeys[row][0].ToString()));
  29. }
  30. Bind();
  31. }

  32. private void Bind()
  33. {
  34. _ls = _sgb.Query();
  35. Grid1.DataSource = _ls;
  36. Grid1.DataBind();
  37. }
  38. }
  39. }
复制代码
页面功能很简单,就是对一个grid里的数据进行删除,删除的功能能实现,并能提交到数据库,断点调试Bind()也能得到执行,返回的_ls的数目也是删除后的数目,也能执行Grid1.DataBind(),可页面就是不能刷新,请教各位大神怎么破啊?



作者: 老李    时间: 2013-8-13 23:19
是没人知道还是不屑于回答这个问题呢?




欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/) Powered by Discuz! X3.4