DataList问题
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
left:10px;
top:13px;
width:987px;
height:100px;
z-index:1;
background-image: url(image/1.gif);
}
#apDiv2 {
position:absolute;
left:183px;
top:79px;
width:653px;
height:40px;
z-index:2;
}
.STYLE3 {font-family: "宋体"; font-size: 14px; font-weight: bold; color: #000000; }
#apDiv3 {
position:absolute;
left:25px;
top:137px;
width:222px;
height:29px;
z-index:1;
}
.STYLE9 { font-size: 14px;
color: #FFFFFF;
}
#apDiv5 { position:absolute;
left:732px;
top:18px;
width:250px;
height:25px;
z-index:5;
}
.STYLE4 { font-family: "宋体";
font-weight: bold;
font-size: 18px;
color: #FFFFFF;
}
.STYLE5 { color: #FF9900;
font-family: "隶书";
font-size: 20px;
}
.STYLE6 { font-family: "宋体";
font-size: 14px;
}
#apDiv4 {
position:absolute;
left:309px;
top:158px;
width:611px;
height:375px;
z-index:6;
}
.STYLE10 {
font-family: "宋体";
font-weight: bold;
font-size: 16px;
}
.STYLE14 {font-size: 13px}
.STYLE15 {color: #3399FF}
.STYLE18 {
font-family: "宋体";
font-weight: bold;
color: #CC0000;
font-size: 14px;
}
.STYLE19 {color: #000000}
.STYLE21 {color: #999999; font-size: 14px; }
.STYLE22 {font-size: 14px}
#apDiv6 {
position:absolute;
left:321px;
top:567px;
width:609px;
height:772px;
z-index:7;
}
.STYLE23 {font-size: 12px}
.STYLE24 {color: #0000FF}
#apDiv7 {
position:absolute;
left:304px;
top:153px;
width:295px;
height:153px;
z-index:6;
}
-->
</style>
</head>
<body>
<form id="form1" runat ="server" >
<div id="apDiv5"><img alt="" src="image/che.gif" width="14" height="16" /><span class="STYLE9">购物车| 帮助中心| 我的帐户| 联系客服 </span></div>
<div id="apDiv1"><a href="shouye.aspx"><img alt="" border="0" src="image/LOGO.jpg" width="132" height="101" /></a></div>
<div id="apDiv3">
<table width="200" border="1" cellpadding="0" cellspacing="0">
<tr>
<td height="29" style =" background-image:url(../image/1.gif)" bgcolor="#ECE9D8"><span class="STYLE4">商品分类</span></td>
</tr>
<tr>
<td><span class="STYLE5">文学</span><br />
<span class="STYLE6">小说|世界名著|散文|传记|武侠|网络小说|推理|言情|文学|诗歌词曲|青春|动漫</span><br />
<br />
<span class="STYLE5">经济管理</span><br />
<span class="STYLE6">管理学|企管|营销|企业家|销售|经济|投资|理财|职场</span><br />
<br />
<span class="STYLE5">生活</span><br />
<span class="STYLE6">家居|美食|旅游|娱乐时尚|家庭|健康|两性|孕产知识</span><br />
<br />
<span class="STYLE5">人文社科</span><br />
<span class="STYLE6">哲学|宗教|艺术|历史|地理|社科|政治|军事|心理学</span><br />
<br />
<span class="STYLE5">计算机与网络</span><br />
<span class="STYLE6">家庭与办公|图形图像|操作系统|程序设计|数据库|软件工程</span><br />
<br />
<span class="STYLE5">教育/科技</span><br />
<span class="STYLE6">建筑|农林|化工|水利|机械|交通|医学|电工技术|电子与通信|科学与自然|外语|考试|教辅|教材</span><br />
<br />
<span class="STYLE5">少儿</span><br />
<span class="STYLE6">低幼|儿童/青少年|游戏|童话<br />
<br />
</span><span class="STYLE5">特色类别</span><br />
<span class="STYLE6">工具书|杂志|进口原版</span><br />
<br />
<span class="STYLE5">其它</span></td>
</tr>
</table>
</div>
<div id="apDiv2">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><span class="STYLE3"><a href="wenxue.aspx">文学·小说</a>|</span></td>
<td align="center" class="STYLE3"><a href="shenghuo.aspx">生活</a>|</td>
<td align="center" class="STYLE3"><a href="renwen.aspx">人文社科</a>|</td>
<td align="center" class="STYLE3"><a href="shaoer.aspx">少儿</a>|</td>
<td align="center" class="STYLE3"><a href="waiyu.aspx">外语·教育</a>|</td>
<td align="center" class="STYLE3"><a href="lizhi.aspx">经管·励志</a>|</td>
<td align="center" class="STYLE3"><a href="yishu.aspx">艺术·设计</a>|</td>
<td align="center" class="STYLE3"><a href="keji.aspx">科技·计算机</a>|</td>
<td align="center" class="STYLE3"><a href="yuanban.aspx">英文原版店</a></td>
</tr>
</table>
</div>
<div id="apDiv7">
<asp:Label ID="Label1" runat="server" Height="14px" Text="生活" Width="34px"></asp:Label>
<table id="TABLE1" runat="server">
<tr>
<td colspan="2" style="height: 66px; width: 187px;">
<asp:DataList ID="myDataList" runat="server" RepeatColumns="2" RepeatDirection="Horizontal" Width="176px" Height="603px" >
<ItemTemplate >
<table style="width: 522px; height: 312px">
<tr>
<td colspan ="2" ><asp:Label runat ="server" ID="name" Text ='<%#DataBinder.Eval(Container.DataItem, "name")%>'></asp:Label>
</td>
</tr>
<tr>
<td colspan ="2">作者:<asp:Label runat ="server" ID ="zuozhe" Text ='<%#DataBinder.Eval(Container.DataItem, "zuozhe")%>'></asp:Label>译者:<asp:Label runat ="server" ID ="yizhe" Text ='<%#DataBinder.Eval(Container.DataItem, "yizhe")%>'></asp:Label>
</td>
</tr>
<tr>
<td style="width: 70px"><asp:Image runat ="server" ID ="image" ImageUrl =<%#DataBinder.Eval(Container.DataItem, "image")%>/></td>
<td style="width: 166px">市场价:<asp:Label runat ="server" ID ="price" Text ='<%#DataBinder.Eval(Container.DataItem, "money")%>'></asp:Label>
<br />
优惠价:<asp:Label runat ="server" ID="newprice" Text ='<%#DataBinder.Eval(Container.DataItem, "money1")%>'></asp:Label>
</td>
</tr>
<tr>
<td style="width: 70px"><asp:Button runat ="server" ID="buy" Text ="购买"/></td>
<td></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList></td>
</tr>
</table>
</div>
</form>
</body>
</html>
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 _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
RepeaterO();
}
private void RepeaterO()
{
string myConnetionString = "server=HYJ-D9XVQ1FCF43\\SQLEXPRESS;uid=sa;pwd=123456;database=gouwu;";
SqlConnection myConnection = new SqlConnection(myConnetionString);
string cmdString = "select * from dbo.shangpin where leixing = '" + Label1.Text + "'";
SqlCommand myCommand = new SqlCommand(cmdString, myConnection);
myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
myDataList.DataSource = myReader;
myDataList.DataBind();
myReader.Close();
myConnection.Close();
}
}
为什么显示不出数据啊~~数据库绑定成功的~