婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > GridView自定義刪除操作的具體方法

GridView自定義刪除操作的具體方法

熱門標簽:世紀佳緣地圖標注怎么去掉 外呼系統費用一年 巫師3為什么地圖標注的財寶沒有 怎么給超市做地圖標注入駐店 手機地圖標注如何刪除 十堰正規電銷機器人系統 寧波自動外呼系統代理 辦理400電話證件 外呼系統代理品牌

首先,我們前端的代碼如下:

復制代碼 代碼如下:

asp:GridView ID="gridViewDxjk" CssClass="gridview" runat="server" AllowPaging="True"
                  DataKeyNames="P_ID" AutoGenerateColumns="False" 
                      RowStyle-HorizontalAlign="Center" BorderWidth="1px" PageSize="17"
                      onrowdeleting="gridViewDxjk_RowDeleting"
                      OnRowDataBound="gridViewDxjk_RowDataBound"
                      onpageindexchanging="gridViewDxjk_PageIndexChanging" >
                        HeaderStyle CssClass="head" />
                        PagerStyle CssClass="pager" />
                        RowStyle CssClass="row" />
                        EditRowStyle CssClass="editrow" />
                        AlternatingRowStyle CssClass="altrow" />
                        EmptyDataRowStyle CssClass="empty" />
                        Columns>                           
                         asp:HyperLinkField HeaderText="編輯" ControlStyle-Width="50" DataNavigateUrlFields="P_ID" DataNavigateUrlFormatString="smsModify.aspx?id={0}" Text="編輯"  >
                                ControlStyle Width="50px">/ControlStyle>/asp:HyperLinkField>
                                asp:CommandField  ShowDeleteButton="true" DeleteText="刪除"   >
                                ControlStyle Width="50px">/ControlStyle>/asp:CommandField>
                                asp:BoundField DataField="P_ID" HeaderText="id" SortExpression="P_ID" ItemStyle-HorizontalAlign="Center"  Visible="False" >
                                ItemStyle HorizontalAlign="Center">/ItemStyle>/asp:BoundField>
                                asp:BoundField DataField="P_NAME" HeaderText="名稱" SortExpression="P_NAME" />
                                asp:BoundField DataField="P_Type" HeaderText="通知方式" SortExpression="P_Type" ItemStyle-HorizontalAlign="Center"  >
                                ItemStyle HorizontalAlign="Center">/ItemStyle>/asp:BoundField>
                                asp:BoundField DataField="P_Fzr" HeaderText="姓名" SortExpression="P_Fzr" ItemStyle-HorizontalAlign="Center"  >
                                ItemStyle HorizontalAlign="Center">/ItemStyle>/asp:BoundField>
                                asp:BoundField DataField="P_tel" HeaderText="通知手機" SortExpression="P_tel" ItemStyle-HorizontalAlign="Center"  >
                                ItemStyle HorizontalAlign="Center">/ItemStyle>/asp:BoundField>
                                asp:BoundField DataField="P_jg" HeaderText="通知間隔(小時)" SortExpression="P_jg" ItemStyle-HorizontalAlign="Center"  >
                                ItemStyle HorizontalAlign="Center">/ItemStyle>/asp:BoundField>
                                asp:BoundField DataField="P_on" HeaderText="是否開啟" SortExpression="P_on" ItemStyle-HorizontalAlign="Center"  >
                                ItemStyle HorizontalAlign="Center">/ItemStyle>/asp:BoundField>
                                asp:BoundField DataField="P_lasttime" HeaderText="最后發送時間" SortExpression="P_lasttime" ItemStyle-HorizontalAlign="Center"  >
                                ItemStyle HorizontalAlign="Center">/ItemStyle>/asp:BoundField>
                                asp:BoundField DataField="P_memo" HeaderText="備注" SortExpression="P_memo" ItemStyle-HorizontalAlign="Center"  >                  
                                ItemStyle HorizontalAlign="Center">/ItemStyle>/asp:BoundField>
                        /Columns>
                        EmptyDataTemplate>
                        沒有數據!
                        /EmptyDataTemplate>
                         PagerTemplate>
                        table width="100%" class="gvPage" style="font-size:12px;">
                            tr>
                            td style="text-align: right">
                                第asp:Label ID="lblPageIndex" runat="server" Text='%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>'>/asp:Label>頁
                                /共asp:Label ID="lblPageCount" runat="server" Text='%# ((GridView)Container.Parent.Parent).PageCount %>'>/asp:Label>頁nbsp;nbsp;
                              asp:LinkButton ID="LinkButtonFirstPage" runat="server" CommandArgument="First" CommandName="Page" Visible="%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">首頁/asp:LinkButton>
                              asp:LinkButton ID="LinkButtonPreviousPage" runat="server" CommandArgument="Prev" CommandName="Page"  Visible="%# ((GridView)Container.NamingContainer).PageIndex != 0 %>">上一頁/asp:LinkButton>
                              asp:LinkButton ID="LinkButtonNextPage" runat="server" CommandArgument="Next" CommandName="Page"  Visible="%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">下一頁/asp:LinkButton>
                              asp:LinkButton ID="LinkButtonLastPage" runat="server" CommandArgument="Last" CommandName="Page"  Visible="%# ((GridView)Container.NamingContainer).PageIndex != ((GridView)Container.NamingContainer).PageCount - 1 %>">尾頁/asp:LinkButton>
                              asp:TextBox ID="txtNewPageIndex" runat="server" Text='%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>'  Width="20px" AutoPostBack="true" >/asp:TextBox>
                              asp:LinkButton ID="btnGoEx" runat="server" CommandArgument="GO" CommandName="Page" Text="GO" OnClick="btnGoEx_Click">/asp:LinkButton>
                            /td>
                            /tr>
                        /table>
                    /PagerTemplate>
                 /asp:GridView>

后端的話,由于需要彈出刪除前的確認框,所以,我們需要在RowDataBound里面做點什么?同時,要想真正的刪除,還需要觸發RowDeleting事件,具體代碼如下:

復制代碼 代碼如下:

//報警刪除
        protected void gridViewDxjk_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string key = gridViewDxjk.DataKeys[e.RowIndex].Value.ToString();
            bool flag = bll.Delete(Int32.Parse(key));
            if (flag)
                NXT_WLService.App_Code.JScript.Alert("刪除成功!", this);
            else
                NXT_WLService.App_Code.JScript.Alert("刪除失敗!", this);
        }

       
        protected void gridViewDxjk_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton btn = (LinkButton)e.Row.Cells[1].Controls[0];
                if (btn.Text.Equals("刪除"))//刪除鈕才加提示訊息 
                    btn.OnClientClick = "if (confirm('你確認要刪除?')) javascript:__doPostBack('gridViewDxjk','Delete$" + e.Row.RowIndex.ToString() + "'); else return false;";
            }
        }

您可能感興趣的文章:
  • GridView分頁的實現以及自定義分頁樣式功能實例
  • GridView自定義分頁的四種存儲過程
  • C#自定義DataGridViewColumn顯示TreeView
  • yii2.0之GridView自定義按鈕和鏈接用法
  • 自定義GridView并且實現拖拽(附源碼)
  • asp.net gridview自定義value值的代碼
  • asp.net gridview分頁:第一頁 下一頁 1 2 3 4 上一頁 最末頁
  • asp.net中的GridView分頁問題
  • Android入門之ActivityGroup+GridView實現Tab分頁標簽的方法
  • asp.net Gridview分頁保存選項
  • 基于GridView和ActivityGroup實現的TAB分頁(附源碼)
  • GridView自定義分頁實例詳解(附demo源碼下載)

標簽:泰州 牡丹江 天門 景德鎮 山西 通遼 平涼 嘉興

巨人網絡通訊聲明:本文標題《GridView自定義刪除操作的具體方法》,本文關鍵詞  GridView,自定義,刪除,操作,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《GridView自定義刪除操作的具體方法》相關的同類信息!
  • 本頁收集關于GridView自定義刪除操作的具體方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 康马县| 大埔区| 鄄城县| 稻城县| 镇宁| 喀喇沁旗| 静宁县| 宜川县| 太康县| 洪泽县| 南部县| 东乡县| 黑水县| 阿尔山市| 余江县| 理塘县| 岑溪市| 德令哈市| 东莞市| 汉寿县| 合山市| 溧水县| 大丰市| 东城区| 汉中市| 南安市| 大同县| 台湾省| 赤水市| 广平县| 灵山县| 和顺县| 平顶山市| 繁峙县| 乌兰浩特市| 蒙自县| 浏阳市| 西乌| 新丰县| 嘉荫县| 宜阳县|