ASP.NET Repeater控件无法显示数据
显示代码<asp:RepeaterID="Repeater1"runat="server"><ItemTemplate><tr><tdheight="26"align="...
显示代码
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr>
<td height="26" align="center" class="bottomxx">
<a href="showdog.aspx?ID=<%#Eval("newsid") %>"><strong><%#Eval("newstitle") %></strong></a></td>
</tr>
</ItemTemplate>
</asp:Repeater>
ascx.cs中数据库连接代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace exzNet
{
public partial class left1 : System.Web.UI.Page
{
exzManage.exzClass exzFunction = new exzNet.exzManage.exzClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Repeater1.DataSource = exzFunction.GetDataTable("select * from netnews where newsclassid=3 order by newsorder desc,newsid desc");
Repeater1.DataBind();
}
}
}
} 展开
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr>
<td height="26" align="center" class="bottomxx">
<a href="showdog.aspx?ID=<%#Eval("newsid") %>"><strong><%#Eval("newstitle") %></strong></a></td>
</tr>
</ItemTemplate>
</asp:Repeater>
ascx.cs中数据库连接代码
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace exzNet
{
public partial class left1 : System.Web.UI.Page
{
exzManage.exzClass exzFunction = new exzNet.exzManage.exzClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Repeater1.DataSource = exzFunction.GetDataTable("select * from netnews where newsclassid=3 order by newsorder desc,newsid desc");
Repeater1.DataBind();
}
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询