亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

asp.net GridView 刪除時彈出確認(rèn)對話框(包括內(nèi)容提示)

 更新時間:2009年12月04日 15:00:24   作者:  
GridView 刪除時彈出確認(rèn)對話框(包括內(nèi)容提示)
效果圖:
 
html代碼
復(fù)制代碼 代碼如下:

<table align="center" bgcolor="#c0de98" border="0" cellpadding="0" cellspacing="1" width="99%">
<tr>
<th colspan="2">
GridView演示</th>
</tr>
<tr>
<td colspan="2" style="width: 100%;" >
<asp:GridView ID="GridView" runat="server" Width="100%" AutoGenerateColumns="False" AllowPaging="True" OnPageIndexChanging="GridView_PageIndexChanging" PageSize="12" OnRowDeleting="GridView_RowDeleting" OnRowDataBound="GridView_RowDataBound" >
<Columns>
<asp:BoundField DataField="UserID" HeaderText="UserID" ReadOnly="True" />
<asp:BoundField DataField="C_Name" HeaderText="中文名字" ReadOnly="True" />
<asp:BoundField DataField="E_Name" HeaderText="英文名字" ReadOnly="True" />
<asp:BoundField DataField="QQ" HeaderText="QQ帳號" />
<asp:CommandField HeaderText="刪除" ShowDeleteButton="True" />
</Columns>
<RowStyle HorizontalAlign="Center" />
<PagerStyle HorizontalAlign="Right" />
</asp:GridView>
</td>
</tr>
</table>      

C#代碼
復(fù)制代碼 代碼如下:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Demo11 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
BindData();
}
}

public void BindData()
{
string strSql = "select UserID,C_Name,E_Name,QQ from Demo_User ";
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.CONN_STRING, CommandType.Text, strSql, null).Tables[0];

GridView.DataSource = dt;
GridView.DataKeyNames = new string[] { "UserID" };//主鍵
GridView.DataBind();
}

protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView.PageIndex = e.NewPageIndex;
BindData();
}

protected void GridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int UserID = (int)GridView.DataKeys[e.RowIndex].Value;
string strSql = "Delete Demo_User where UserID=@UserID";
SqlParameter[] para = {
new SqlParameter("@UserID", UserID),
};
SqlHelper.ExecuteNonQuery(SqlHelper.CONN_STRING, CommandType.Text, strSql, para);
BindData();
}

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你確認(rèn)要刪除:\"" + e.Row.Cells[1].Text + "\"嗎?')");
}
}
}
}

相關(guān)文章

  • 刪除特殊字符和限定用戶輸入長度的示例代碼

    刪除特殊字符和限定用戶輸入長度的示例代碼

    在填寫注冊表單時工程師妹都會考慮到刪除特殊字符和限定用戶輸入長度等等,下面有個不錯的示例,感興趣的朋友可以參考下
    2013-10-10
  • asp.net+jquery Jsonp使用方法

    asp.net+jquery Jsonp使用方法

    Jsonp的用法非常簡單,不過需要服務(wù)器端和客戶端同時支持。
    2010-04-04
  • .NET 6開發(fā)TodoList應(yīng)用實現(xiàn)結(jié)構(gòu)搭建

    .NET 6開發(fā)TodoList應(yīng)用實現(xiàn)結(jié)構(gòu)搭建

    這篇文章主要介紹了.NET 6開發(fā)TodoList應(yīng)用實現(xiàn)結(jié)構(gòu)搭建,上一篇我們講解了實現(xiàn)系列背景 ,今天繼續(xù)來講講.NET 6開發(fā)TodoList并且實現(xiàn)結(jié)構(gòu)搭建,更多詳細(xì)內(nèi)容剛興趣得小伙伴可以來參考一下下面文章得具體內(nèi)容
    2021-12-12
  • dz asp.net論壇中函數(shù)--根據(jù)Url獲得源文件內(nèi)容

    dz asp.net論壇中函數(shù)--根據(jù)Url獲得源文件內(nèi)容

    從asp.net dz論壇發(fā)現(xiàn)的這個函數(shù),學(xué)習(xí)一下高手的經(jīng)驗代碼
    2008-09-09
  • .NET簡單工廠模式講解

    .NET簡單工廠模式講解

    這篇文章主要為大家詳細(xì)介紹了ASP.NET簡單工廠模式的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • asp.net批量多選文件上傳解決方案

    asp.net批量多選文件上傳解決方案

    這篇文章主要介紹了asp.net批量多選文件上傳解決方案,基于flex開發(fā)的一個多選上傳功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2015-08-08
  • 頁面編碼codepage=936和65001的區(qū)別

    頁面編碼codepage=936和65001的區(qū)別

    這篇文章主要介紹了頁面編碼codepage=936和65001的區(qū)別,需要的朋友可以參考下
    2015-07-07
  • .Net Core學(xué)習(xí)教程之在Mvc中簡單的使用日志組件

    .Net Core學(xué)習(xí)教程之在Mvc中簡單的使用日志組件

    這篇文章主要給大家介紹了關(guān)于.Net Core學(xué)習(xí)教程之在Mvc中簡單使用日志組件的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-06-06
  • .net core 使用阿里云分布式日志的配置方法

    .net core 使用阿里云分布式日志的配置方法

    本文給大家分享.net core 使用阿里云分布式日志的實現(xiàn)代碼,簡單查詢阿里云日志的工具使用,通過實例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-06-06
  • C#中常用的分頁存儲過程小結(jié)

    C#中常用的分頁存儲過程小結(jié)

    C#中常用的分頁存儲過程小結(jié),需要利用存儲過程分頁的朋友可以參考下。
    2010-05-05

最新評論