html绑定数据代码:<div id="articleContent" >
<div style="width: 658px; height: 466px;" >
<asp:Label ID="Label1" runat="server" Text="Label" Width="176px"><%# ds.Tables[0].Rows[0][1].ToString() %></asp:Label>
</div>
<div>
<%# ds.Tables[0].Rows[0][2],"ArticleContent") %>
</div>
</div>后台的代码:public partial class Default2 : System.Web.UI.Page
{
DataBase db = new DataBase();
public DataSet ds ;
protected void Page_Load(object sender, EventArgs e)
{
int articleID = Convert.ToInt32(Request.QueryString["ID"]);
ds = db.getDs("select * from article where articleId=" + articleID);
}
为什么我这样绑定,而且数据库有数据,可却现实不出来???
<div style="width: 658px; height: 466px;" >
<asp:Label ID="Label1" runat="server" Text="Label" Width="176px"><%# ds.Tables[0].Rows[0][1].ToString() %></asp:Label>
</div>
<div>
<%# ds.Tables[0].Rows[0][2],"ArticleContent") %>
</div>
</div>后台的代码:public partial class Default2 : System.Web.UI.Page
{
DataBase db = new DataBase();
public DataSet ds ;
protected void Page_Load(object sender, EventArgs e)
{
int articleID = Convert.ToInt32(Request.QueryString["ID"]);
ds = db.getDs("select * from article where articleId=" + articleID);
}
为什么我这样绑定,而且数据库有数据,可却现实不出来???
必须在调用控件的DataBind()方法时,才会去执行<%#%>里面的语句int articleID = Convert.ToInt32(Request.QueryString["ID"]);
ds = db.getDs("select * from article where articleId=" + articleID);
Page.DataBind()