Chinaunix首页 | 论坛 | 博客
  • 博客访问: 307595
  • 博文数量: 128
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1611
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-19 11:49
文章分类

全部博文(128)

文章存档

2018年(2)

2016年(2)

2014年(10)

2013年(114)

我的朋友

分类: C#/.net

2013-09-10 15:12:51


点击(此处)折叠或打开

  1. <asp:GridView ID="gridViewDxjk" CssClass="gridview" runat="server" AllowPaging="True"
  2.                   DataKeyNames="P_ID" AutoGenerateColumns="False"
  3.                       RowStyle-HorizontalAlign="Center" BorderWidth="1px" PageSize="17"
  4.                       onrowdeleting="gridViewDxjk_RowDeleting"
  5.                       OnRowDataBound="gridViewDxjk_RowDataBound"
  6.                       onpageindexchanging="gridViewDxjk_PageIndexChanging" >
  7.                         <HeaderStyle CssClass="head" />
  8.                         <PagerStyle CssClass="pager" />
  9.                         <RowStyle CssClass="row" />
  10.                         <EditRowStyle CssClass="editrow" />
  11.                         <AlternatingRowStyle CssClass="altrow" />
  12.                         <EmptyDataRowStyle CssClass="empty" />
  13.                         <Columns>
  14.                          <asp:HyperLinkField HeaderText="编辑" ControlStyle-Width="50" DataNavigateUrlFields="P_ID" DataNavigateUrlFormatString="smsModify.aspx?id={0}" Text="编辑" >
  15.                                 <ControlStyle Width="50px"></ControlStyle></asp:HyperLinkField>
  16.                                 <asp:CommandField ShowDeleteButton="true" DeleteText="删除" >
  17.                                 <ControlStyle Width="50px"></ControlStyle></asp:CommandField>
  18.                                 <asp:BoundField DataField="P_ID" HeaderText="id" SortExpression="P_ID" ItemStyle-HorizontalAlign="Center" Visible="False" >
  19.                                 <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
  20.                                 <asp:BoundField DataField="P_NAME" HeaderText="名称" SortExpression="P_NAME" />
  21.                                 <asp:BoundField DataField="P_Type" HeaderText="通知方式" SortExpression="P_Type" ItemStyle-HorizontalAlign="Center" >
  22.                                 <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
  23.                                 <asp:BoundField DataField="P_Fzr" HeaderText="姓名" SortExpression="P_Fzr" ItemStyle-HorizontalAlign="Center" >
  24.                                 <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
  25.                                 <asp:BoundField DataField="P_tel" HeaderText="通知手机" SortExpression="P_tel" ItemStyle-HorizontalAlign="Center" >
  26.                                 <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
  27.                                 <asp:BoundField DataField="P_jg" HeaderText="通知间隔(小时)" SortExpression="P_jg" ItemStyle-HorizontalAlign="Center" >
  28.                                 <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
  29.                                 <asp:BoundField DataField="P_on" HeaderText="是否开启" SortExpression="P_on" ItemStyle-HorizontalAlign="Center" >
  30.                                 <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
  31.                                 <asp:BoundField DataField="P_lasttime" HeaderText="最后发送时间" SortExpression="P_lasttime" ItemStyle-HorizontalAlign="Center" >
  32.                                 <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
  33.                                 <asp:BoundField DataField="P_memo" HeaderText="备注" SortExpression="P_memo" ItemStyle-HorizontalAlign="Center" >
  34.                                 <ItemStyle HorizontalAlign="Center"></ItemStyle></asp:BoundField>
  35.                         </Columns>
  36.                         <EmptyDataTemplate>
  37.                         没有数据!
  38.                         </EmptyDataTemplate>
  39.                          <PagerTemplate>
  40.                         <table width="100%" class="gvPage" style="font-size:12px;">
  41.                             <tr>
  42.                             <td style="text-align: right">
  43.                                 第<asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>'></asp:Label>
  44.                                 /共<asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount %>'></asp:Label>
  45.                               <asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page" Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">首页</asp:LinkButton>
  46.                               <asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page" Visible="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">上一页</asp:LinkButton>
  47.                               <asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page" Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">下一页</asp:LinkButton>
  48.                               <asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page" Visible="<%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">尾页</asp:LinkButton>
  49.                               <asp:TextBox ID="txtNewPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' Width="20px" AutoPostBack="true" ></asp:TextBox>
  50.                               <asp:LinkButton ID="btnGoEx" runat="server" CommandArgument="GO" CommandName="Page" Text="GO" OnClick="btnGoEx_Click"></asp:LinkButton>
  51.                             </td>
  52.                             </tr>
  53.                         </table>
  54.                     </PagerTemplate>
  55.                  </asp:GridView>
unity3d教程
后端的话,由于需要弹出删除前的确认框,所以,我们需要在RowDataBound里面做点什么?同时,要想真正的删除,还需要触发RowDeleting事件,具体代码如下:



点击(此处)折叠或打开

  1. //报警删除
  2.         protected void gridViewDxjk_RowDeleting(object sender, GridViewDeleteEventArgs e)
  3.         {
  4.             string key = gridViewDxjk.DataKeys[e.RowIndex].Value.ToString();
  5.             bool flag = bll.Delete(Int32.Parse(key));
  6.             if (flag)
  7.                 NXT_WLService.App_Code.JScript.Alert("删除成功!", this);
  8.             else
  9.                 NXT_WLService.App_Code.JScript.Alert("删除失败!", this);
  10.         }

  11.        
  12.         protected void gridViewDxjk_RowDataBound(object sender, GridViewRowEventArgs e)
  13.         {
  14.             if (e.Row.RowType == DataControlRowType.DataRow)
  15.             {
  16.                 LinkButton btn = (LinkButton)e.Row.Cells[1].Controls[0];
  17.                 if (btn.Text.Equals("删除"))//刪除鈕才加提示訊息
  18.                     btn.OnClientClick = "if (confirm('你确认要删除?')) javascript:__doPostBack('gridViewDxjk','Delete$" + e.Row.RowIndex.ToString() + "'); else return false;";
  19.             }
  20.         }



阅读(597) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~