All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
详细讲解PHP中缓存技术的应用_php资料_编程技术
.NET2.0App_Code文件夹的使用_[Asp.Net教程]
VS2005和ASP.NET2.0中使用强类型数据_[Asp.Net教程]
安全攻略:PHP脚本木马的高级防范_php资料_编程技术
避免Access和SQL,Server的空值冲突_[SQL,Server教程]
基础知识:php4和php5区别_php资料_编程技术
用php或js获取图片大小,高宽尺寸_[PHP教程]
PHP程序指定目录里的指定后缀名文件为超连接_php资料_编程技术
重新计算自动编号_[SQL,Server教程]
由浅入深学习动态网页制作PHP的编程与应用_php资料_编程技术
Reading number is top 10 pictures
邪恶搞笑内涵图
Sora aoi in China1
美洲杯宝贝的雨中风情1
2012 national geographic daily picture9
海底兵马俑
八个盛产美女的国家1
So beauty, will let you spray blood10
Players in the eyes of a perfect love2
刘亦菲写真集1
运动的范冰冰3
Download software ranking
C++教程第四版
塘西风月痕
卡丁车单机版
Tram sex maniac 2 (H) rar bag9
Unix video tutorial14
Ashlynn Video2
Desire a peach blossom
Boxer Classic video2
C#COM编程指南
Sora aoi, the nurse, uniform ,nursing assistant
delv published in(发表于) 2014/1/24 9:02:07 Edit(编辑)
.NET2.0在Repeater中实现删除_[Asp.Net教程]

.NET2.0在Repeater中实现删除_[Asp.Net教程]

.NET2.0在Repeater中实现删除_[Asp.Net教程]

虽然Repeater控件没有象GridView那样常用,但有一些特定的场合还是需要用到Repeater的,其实在Net2.0中,FormView控件也可以实现类似于Repeater的效果,而且都是通过模板(Template)来显示数据。


然而,在Repeater控件对控件进行删除就没有GridView那样简单。下面示例如下:


Default.aspx:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Repeater_Default" %>





无标题页





SelectCommand="SELECT * FROM [Region]">




























Default.aspx.cs:


using System;
using System.Data;
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;
using System.Data.SqlClient;


public partial class Repeater_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{


}
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{

switch (((Button)e.Item.FindControl ("Button1")).Text)
{
case "Delete":


SqlConnection conn = new SqlConnection("server=.;database=northwind;uid=sa;pwd=sa;");
conn.Open();
SqlCommand comm = new SqlCommand("delete from region where regionid='" + ((Label)e.Item.FindControl("Label1")).Text+"'",conn );
comm.ExecuteNonQuery();
conn.Close();


Response.Write(((Label)e.Item.FindControl ("Label1")).Text);
break;
}
}
protected void Repeater1_ItemCreated(object sender, RepeaterItemEventArgs e)
{
for (int i = 0; i < this.Repeater1.Items.Count; i++)
{
((Button)this.Repeater1.Items[i].FindControl("Button1")).Attributes.Add("onclick", "alert('ff')");
}

}
}


这样就可以实现删除了。


来源:sdtsfhh的blog







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.