最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2009年12月04日 15:00:24   作者:  
GridView 刪除時(shí)彈出確認(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)要?jiǎng)h除:\"" + e.Row.Cells[1].Text + "\"嗎?')");
}
}
}
}

相關(guān)文章

  • 詳解mvc使用JsonResult返回Json數(shù)據(jù)

    詳解mvc使用JsonResult返回Json數(shù)據(jù)

    這篇文章主要介紹了詳解mvc使用JsonResult返回Json數(shù)據(jù),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-01-01
  • 微信JS-SDK分享功能的.Net實(shí)現(xiàn)代碼

    微信JS-SDK分享功能的.Net實(shí)現(xiàn)代碼

    這篇文章主要介紹了微信JS-SDK分享功能的.Net實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下
    2017-09-09
  • Datatable刪除行的Delete和Remove方法的區(qū)別介紹

    Datatable刪除行的Delete和Remove方法的區(qū)別介紹

    Datatable刪除行的Delete和Remove方法的區(qū)別介紹,需要的朋友可以參考一下
    2013-03-03
  • ASP.NET 通過攔截器記錄錯(cuò)誤日志的示例代碼

    ASP.NET 通過攔截器記錄錯(cuò)誤日志的示例代碼

    這篇文章主要介紹了ASP.NET 通過攔截器記錄錯(cuò)誤日志的示例代碼,幫助大家更好的理解和學(xué)習(xí)使用.NET技術(shù),感興趣的朋友可以了解下
    2021-04-04
  • asp.net利用google的api做翻譯

    asp.net利用google的api做翻譯

    google提供了一組API可以給我們很方便的實(shí)現(xiàn)語言翻譯功能,對于我們(中國人)而言,常用的是中文與英文的互譯。
    2009-05-05
  • asp.net 預(yù)防SQL注入攻擊之我見

    asp.net 預(yù)防SQL注入攻擊之我見

    說起防止SQL注入攻擊,感覺很郁悶,這么多年了大家一直在討論,也一直在爭論,可是到了現(xiàn)在似乎還是沒有定論。當(dāng)不知道注入原理的時(shí)候會覺得很神奇,怎么就被注入了呢?會覺得很難預(yù)防。但是當(dāng)知道了注入原理之后預(yù)防不就是很簡單的事情了嗎?
    2009-11-11
  • 利用委托把用戶控件的值顯示于網(wǎng)頁案例應(yīng)用

    利用委托把用戶控件的值顯示于網(wǎng)頁案例應(yīng)用

    用戶控件(UserControl)是集成一個(gè)功能,需要處理好的數(shù)據(jù),然后存數(shù)據(jù)庫中并顯示于網(wǎng)頁上,讓用戶能檢測到處理的數(shù)據(jù)情況,接下來將介紹利用委托把用戶控件的值顯示于網(wǎng)頁上,感興趣的朋友可以了解下
    2013-02-02
  • asp.net Coolite TablePanel使用

    asp.net Coolite TablePanel使用

    TabPanel控件使用非常簡單,但是功能卻非常強(qiáng)大,它同MenuPanel、TreePanel一樣提供了很多的集合屬性,可以定制出豐富的應(yīng)用。
    2010-03-03
  • .NET8實(shí)現(xiàn)PDF合并的示例代碼

    .NET8實(shí)現(xiàn)PDF合并的示例代碼

    這篇文章主要為大家詳細(xì)介紹了如何使用.NET8實(shí)現(xiàn)PDF合并的效果,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-12-12
  • ASP.NET Core依賴注入系列教程之服務(wù)的注冊與提供

    ASP.NET Core依賴注入系列教程之服務(wù)的注冊與提供

    這篇文章主要給大家介紹了關(guān)于ASP.NET Core依賴注入系列教程之服務(wù)的注冊與提供的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧
    2018-11-11

最新評論

兰西县| 永川市| 水城县| 贵南县| 鲁山县| 海丰县| 辉南县| 井研县| 铁力市| 龙门县| 安化县| 洞头县| 淮滨县| 连城县| 邵阳县| 江门市| 郸城县| 瑞安市| 舞阳县| 漯河市| 陵川县| 盱眙县| 乾安县| 年辖:市辖区| 临泽县| 家居| 沈丘县| 泊头市| 芦溪县| 平乐县| 锦屏县| 兴化市| 贞丰县| 乌拉特后旗| 明光市| 柳河县| 水城县| 闸北区| 淄博市| 共和县| 柳河县|