我正在使用<%#Eval("sectionId") %>
数据绑定表达式将数据绑定到我的代码前置。 我在我的代码behinde使用下面的代码设置此sectionId,Eval()显示空值
public partial class ProductDetails : System.Web.UI.Page
{
private string sectionId = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString.Count > 0)
{
if (Request.QueryString["secId"] != null || Request.QueryString["prodId"] != null)
{
sectionId = Request.QueryString["secId"].ToString();
}
}
}
}
}
凡在我.aspx页面中我有这样的代码,
<a href="SectionWiseProduct.aspx?secId=<%#Eval("sectionId") %>">Enviro Section</a>
为sectionId每次值已成功设置在代码behinde但它不会反映在UI page.every时间我得到喜欢的链接,
SectionWiseProduct.aspx?secId=
任何人可以请建议是我这样做对还是我有没有其他的方式来做到这一点。 而且page_Load会调用两次,这是因为Eval吗?
,感谢您的回复,你可以建议我任何解决方案,我可以将数据绑定到纯HTML控件。因为我想将数据绑定到''标签。 – 2012-03-09 13:12:55
是的,请确保标签在服务器上运行,并将其绑定到ItemDataBound事件中,这很容易做到,以后可读性更强。 – 2012-03-09 14:58:46