asp.net中DataList数据绑定问题

来源:百度知道 编辑:UC知道 时间:2024/06/19 16:10:29
购物网站,用C#语言asp.net技术。
做的是前台DataList控件绑定数据库数据,但是没有显示出来。
用户控件代码:<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Bargain_Price_Product.ascx.cs" Inherits="UserControl_Bargain_Price_Product" %>
<table width="518" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td><img alt="" src="images/tj.gif" width="560" height="30" border="0" usemap="#Map1" /></td>
</tr>
<tr>
<td>
<asp:DataList runat="server" ID="Bargain_Price_Product_List" RepeatColumns="4" Repeatdirection="Horizontal">
<ItemTemplate>
<div align="left">
<table width="140" s

Bargain_Price_Product_List.DataSource = p.Banding().Tables[0];
后面加上:
Bargain_Price_Product_List.Databind();

后台datalist绑定代码没写吧?
string sql=("你在数据库要查的字段");
DataList1.DataSource = operateData.getRows(sql).DefaultView;
DataList1.DataBind();

protected void Page_Load(object sender, EventArgs e)
{
Bll.product p = new Bll.product();
Bargain_Price_Product_List.DataSource = p.Banding().Tables[0];
Bargain_Price_Product_List.DataBind();