博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
repeater练习
阅读量:4601 次
发布时间:2019-06-09

本文共 1516 字,大约阅读时间需要 5 分钟。

namespace repeater {
public partial class itemdatabound : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
} protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) {
DataRowView drv = (DataRowView)e.Item.DataItem; var row=drv.Row; string name= (string)row.ItemArray[2]; if (name == "1") {
HtmlGenericControl span=(HtmlGenericControl)e.Item.FindControl("span1");//span行变成红色 span.Style["background-color"] = "red"; //TextBox text=(TextBox)e.Item.FindControl("TextBox1");//文本框背景变成红色 //text.BackColor = Color.Red; } } protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) {
if (e.CommandName == "add") {
using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True")) { conn.Open(); SqlCommand cmd = new SqlCommand("update images set name=name+1 where id=@id", conn); int id = Convert.ToInt32(e.CommandArgument); SqlParameter para = new SqlParameter("@id", id); cmd.Parameters.Add(para); cmd.ExecuteNonQuery(); } Repeater1.DataBind();//强制刷新数据 } } } }

 

转载于:https://www.cnblogs.com/zwjblogs/archive/2012/03/02/2377628.html

你可能感兴趣的文章
WebAPI常见的鉴权方法,及其适用范围
查看>>
08. 删除重复&海量数据
查看>>
重新想象 Windows 8 Store Apps (71) - 其它: C# 调用 C++
查看>>
发布mvc遇到的HTTP错误 403.14-Forbidden解决办法
查看>>
记录一些好用的工具
查看>>
超链接样式设置(去下划线)(转)
查看>>
restcontroller和controller区别
查看>>
2016012003+陈琦+散列函数的应用及其安全性
查看>>
Android 状态栏通知Notification、NotificationManager详解
查看>>
Sublime Text 3中使用正则表达式删除空行
查看>>
UIApplicationDelegate协议
查看>>
再谈iOS 7的手势滑动返回功能
查看>>
Jmeter测试dubbo接口填坑
查看>>
python小练——找出指定目录下小于指定字节的文件,输出到文本文件
查看>>
渐渐磨砺--16年11月封闭总结
查看>>
[zz]GDB调试精粹及使用实例
查看>>
数据库的创建和删除
查看>>
最简单的三层实例【插入据
查看>>
设计模式学习笔记——Prototype原型模式
查看>>
pom.xml里有红叉报错的解决办法
查看>>