DataList数据的绑定
2016-03-04 17:52
225 查看
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="WebApplication1.Index" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .style1 { width: 100%; } </style> </head> <body> <form id="form1" runat="server"> <div> <asp:DataList ID="DataList1" runat="server" onselectedindexchanged="DataList1_SelectedIndexChanged" RepeatColumns="3" RepeatDirection="Horizontal"> <ItemTemplate> <table class="style1"> <tr> <td rowspan="3"> <asp:Image ID="Image1" runat="server" Height="120px" ImageUrl='<%# Eval("pic") %>' Width="100px" /> </td> <td> <asp:Label ID="Label1" runat="server" Text='<%# Eval("price") %>'></asp:Label> </td> </tr> <tr> <td> <asp:Label ID="Label2" runat="server" Text='<%# Eval("sprice") %>'></asp:Label> </td> </tr> <tr> <td> <asp:ImageButton ID="ImageButton1" runat="server" CommandArgument='<%# Eval("pid") %>' ImageUrl="~/images/MenuPic/edit.gif" onclick="ImageButton1_Click" /> <asp:ImageButton ID="ImageButton2" runat="server" CommandArgument='<%# Eval("pid") %>' ImageUrl="~/images/MenuPic/delete.gif" /> </td> </tr> </table> </ItemTemplate> </asp:DataList> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; namespace WebApplication1 { public partial class Index : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BingList(); } } private void BingList() { string sql = "select * from product"; DataTable dt = SQLHelper.GetTable(sql); DataList1.DataSource = dt; DataList1.DataBind(); } } }
相关文章推荐
- 6-9-哈夫曼树(HuffmanTree)-树和二叉树-第6章-《数据结构》课本源码-严蔚敏吴伟民版
- String学习之-深入解析String#intern
- 命令行编译/安装/运行/卸载IOS APP
- 去掉详细页网址中的日期 简化详细页的地址
- python 示例:始用PIL库图片操作实例 缩放与模糊
- JEE&Mysql&Tomcat开发总结一
- 获取网络gif时候报错 <Error>: ImageIO: _CGImagePluginInitGIF malformed GIF frame#0
- 怎样制作web版的folder treeview
- iOS3D-Touch开发之Home Screen Quick Actions(Swift)
- HDU 2802 F(N) [Ad Hoc]
- Javac编译过程
- 面试
- REST and SOAP
- Javac编译过程
- 一、java基础
- LintCode Wiggle Sort II
- maven + eclipse(Mars.2 Release (4.5.2))错误异常处理
- iOS开发 之 可穿戴设备 蓝牙4.0 BLE 开发
- Hbase总结:Hbase中的Coprocessor
- Restful Web Service