您现在的位置是:网站首页> 编程资料编程资料
asp.net Repeater 数据绑定的具体实现(图文详解)_实用技巧_
2023-05-24
259人已围观
简介 asp.net Repeater 数据绑定的具体实现(图文详解)_实用技巧_
以下为设计步骤:

1、在C# 中连接数据库。如下图:
2、在项目中添加新建项,建立一个数据集,并把Categories从服务器资源列表中拖到这个数据集模板中并点击菜单“生成-生成解决方案”,如下图:

3、在aspx的webform上放一个ObjectDataSource控件,设定它的TypeName为刚刚建立的数据集类型,用它的向导建立即可。
4、在aspx的webform上放一个Repeater控件,用它的向导设定它的DataSourceID为上面的ObjectDataSource
5、在网页中设定它的源码,即加上
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Repeater.Default" %>
7、要求在类别名称中带"O"的编辑框显示红色,则写出以下代码:
复制代码 代码如下:
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem)
{
TextBox tb = (TextBox)e.Item.FindControl("TextBox1");
if (tb.Text.Contains("o"))
{
tb.BackColor = Color.Red;
}
}
}
7、运行显示的效果为:

您可能感兴趣的文章:
- ASP.NET repeater添加序号列的方法
- asp.net Repeater取得CheckBox选中的某行某个值的c#写法
- asp.net repeater手写分页实例代码
- asp.net Repeater之非常好的数据分页
- asp.net中让Repeater和GridView支持DataPager分页
- asp.net 遍历repeater中的控件的几种方式
- asp.net下Repeater使用 AspNetPager分页控件
- asp.net repeater实现批量删除
- asp.net Repeater控件的说明及详细介绍及使用方法
- asp.net Repeater 数据绑定代码
- JQuery实现Repeater无刷新批量删除(附后台asp.net源码)
- 决定何时使用 DataGrid、DataList 或 Repeater(ASP.NET 技术文章)
- ASP.NET笔记之 Repeater的使用
- asp.net DataList与Repeater用法区别
- 详解ASP.NET数据绑定操作中Repeater控件的用法
相关内容
- VS2010 水晶报表的使用方法_实用技巧_
- Asp.net获取客户端IP常见代码存在的伪造IP问题探讨_实用技巧_
- Asp.Net 无刷新文件上传并显示进度条的实现方法及思路_实用技巧_
- HTTP错误500.19解决方法(定义了重复的节点)_实用技巧_
- Gridview用法大总结(全程图解珍藏版)_实用技巧_
- asp.net中javascript的引用(直接引入和间接引入)_实用技巧_
- DataGridView - DataGridViewCheckBoxCell的使用介绍_实用技巧_
- 三层+存储过程实现分页示例代码_实用技巧_
- ASP.NET中操作SQL数据库(连接字符串的配置及获取)_实用技巧_
- asp.net页面传值测试实例代码(前后台)_实用技巧_
