在Reapter控件里显示数据库数据
时间:2015/11/7 13:37:00来源:互联网 作者:flyso 点击: 1145 次
aspx: <asp:Repeater ID="Repeater1" runat="server" > <HeaderTemplate> <table class="STYLE2" border="0" cellpadding="1" cellspacing="1" style="border-right:#CC6600 thin dotted; border-top:#CC6600 thin dotted; border-left:#CC6600 thin dotted; width: 480px; border-bottom:#CC6600 thin dotted; background-color: #333333; color: #ffffff; text-decoration: none;"> <tr> <th bgcolor="#CC6600" style="width:40px ;">编号</th><th bgcolor="#CC66OO" style="width:150px">歌名</th><th bgcolor="#CC6600" style="width:30px">试听</th><th bgcolor="#CC6600" style="width:60px">点击率</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td bgcolor="#666666"> <asp:Label runat="server" ID="LblSongID" Text='<%# Eval("SongID") %>' /> </td> <td bgcolor="#666666"> <asp:Label runat="server" ID="LblSongName" Text='<%# Eval("SongName") %>' /> </td> <td bgcolor="#666666" style="width:30px;"> <a href="sound.html" target="_blank" ><img src="images/play.gif" border="0" alt="点击试听"/></a> </td> <td bgcolor="#666666"> <asp:Label runat="server" ID="LblSongStat" Text='<%# Eval("SongStat") %>' /> </td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater>
cs: protected void Page_Load(object sender, EventArgs e) { SqlDataSource SongDataSource = new SqlDataSource(); SongDataSource.ConnectionString = SqlHelper.ConnectionStringLocalTransaction; SongDataSource.DataSourceMode = SqlDataSourceMode.DataSet; SongDataSource.SelectCommandType = SqlDataSourceCommandType.Text; SongDataSource.SelectCommand = "Select * FROM [80NT] where ID =下拉列表选择的文本 orDER BY [ID]"; this.Repeater1.DataSource = SongDataSource; this.Repeater1.DataBind(); } |