代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Asp.Net
】
DataList中HyperLink和LinkButton的数据绑定示例
作者:
Dezai.CN
/ 发布于
2011/8/11
/
798
<div> <span style="background-color: #ffff99"><strong>aspx网页</strong></span> <span style="background-color: #ffff99"><%@ Page Language="C#" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %></span> <span style="background-color: #ffff99"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "</span><a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><span style="background-color: #ffff99"><font color="#983d9e">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</font></span></a><span style="background-color: #ffff99">"></span> <span style="background-color: #ffff99"><html xmlns="</span><a href="http://www.w3.org/1999/xhtml"><span style="background-color: #ffff99"><font color="#983d9e">http://www.w3.org/1999/xhtml</font></span></a><span style="background-color: #ffff99">"> <head id="Head1" runat="server"> </span><span style="background-color: #ffff99"><title></title> </head> <body> </span><span style="background-color: #ffff99"><form id="form1" runat="server"> </span><span style="background-color: #ffff99"><div> </span><span style="background-color: #ffff99"><asp:DataList ID="DataList1" runat="server"> </span><span style="background-color: #ffff99"> </span><span style="background-color: #ffff99"><ItemTemplate> </span><span style="background-color: #ffff99"><asp:HyperLink runat="server" ID="hl" </span><span style="background-color: #ffff99">NavigateUrl='<%# "./playFLV.aspx?flvurl="+eval_r("ID") %>' </span><span style="background-color: #ffff99">Text='<%# eval_r("name") %>' ></asp:HyperLink> </span><span style="background-color: #ffff99"><asp:LinkButton runat="server" ID="lb" Text='<%# eval_r("name") %>' </span><span style="background-color: #ffff99">CommandArgument='<%# eval_r("ID") %>' oncommand="lb_Command"></asp:LinkButton> </span><span style="background-color: #ffff99"></ItemTemplate> </span><span style="background-color: #ffff99"></asp:DataList> </span><span style="background-color: #ffff99"></div> </span><span style="background-color: #ffff99"></form> </body> </html></span> <span style="background-color: #ffff99"><strong>源码</strong></span> <span style="background-color: #ffff99">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls;</span> <span style="background-color: #ffff99">namespace WebApplication1 { </span><span style="background-color: #ffff99">/// <summary> </span><span style="background-color: #ffff99">///Product 的摘要说明 </span><span style="background-color: #ffff99">/// </summary> </span><span style="background-color: #ffff99">public class Product </span><span style="background-color: #ffff99">{ </span><span style="background-color: #ffff99">public Product() </span><span style="background-color: #ffff99">{</span> <span style="background-color: #ffff99">}</span> <span style="background-color: #ffff99">/// <summary> </span><span style="background-color: #ffff99">/// 编号 </span><span style="background-color: #ffff99">/// </summary> </span><span style="background-color: #ffff99">public int ID { get; set; } </span><span style="background-color: #ffff99">/// <summary> </span><span style="background-color: #ffff99">/// 类别 </span><span style="background-color: #ffff99">/// </summary> </span><span style="background-color: #ffff99">public string url { get; set; }</span> <span style="background-color: #ffff99">/// <summary> </span><span style="background-color: #ffff99">/// 名称 </span><span style="background-color: #ffff99">/// </summary> </span><span style="background-color: #ffff99">public string Name { get; set; } </span><span style="background-color: #ffff99">}</span> <span style="background-color: #ffff99">public partial class WebForm2 : System.Web.UI.Page </span><span style="background-color: #ffff99">{ </span><span style="background-color: #ffff99">protected void Page_Load(object sender, EventArgs e) </span><span style="background-color: #ffff99">{ </span><span style="background-color: #ffff99">if (!IsPostBack) </span><span style="background-color: #ffff99">{ </span><span style="background-color: #ffff99">List<Product> list = new List<Product>(); </span><span style="background-color: #ffff99">list.Add(new Product() { ID = 1, url = @"./playFLV.aspx?flvurl=1", Name = @"奔驰" }); </span><span style="background-color: #ffff99">list.Add(new Product() { ID = 3, url = @"./playFLV.aspx?flvurl=2", Name = @"项链" }); </span><span style="background-color: #ffff99">list.Add(new Product() { ID = 2, url = @"./playFLV.aspx?flvurl=3", Name = @"宝马" }); </span><span style="background-color: #ffff99">list.Add(new Product() { ID = 4, url = @"./playFLV.aspx?flvurl=4", Name = @"戒指" }); </span><span style="background-color: #ffff99">list.Add(new Product() { ID = 5, url = @"./playFLV.aspx?flvurl=5", Name = @"奔驰" }); </span><span style="background-color: #ffff99">list.Add(new Product() { ID = 6, url = @"./playFLV.aspx?flvurl=6", Name = @"耳环" });</span> <span style="background-color: #ffff99">this.DataList1.DataSource = list; </span><span style="background-color: #ffff99">this.DataList1.DataBind(); </span><span style="background-color: #ffff99">}</span> <span style="background-color: #ffff99">}</span> <span style="background-color: #ffff99"> </span><span style="background-color: #ffff99">protected void lb_Command(object sender, CommandEventArgs e) </span><span style="background-color: #ffff99">{ </span><span style="background-color: #ffff99">Response .Redirect (@"./playFLV.aspx?flvurl="+ e.CommandArgument.ToString()); </span><span style="background-color: #ffff99">} </span><span style="background-color: #ffff99">} }</span> </div>
试试其它关键字
HyperLink
同语言下
.
gzip压缩
.
实现http多线程断点续传下载文件
.
实现多线程断点续传下载大文件
.
生成字符串的 CheckSum
.
根据 UserAgent 获取浏览器的类型和版本
.
根据 Agent 判断是否是智能手机
.
隐藏手机号中间四位为*方法
.
合并图片(二维码和其他图片合并)
.
ASP.NET CORE中判断是否移动端打开网页
.
ASP.NET(C#)实现页面计时(定时)自动跳转
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3