一个HyperLink控件(在DataList项模板内),我把它的Text属性绑定了,绑定表达式如下:
DataBinder.Eval(Container.DataItem,"N_title")当点击那个HyperLink时我想跳转到另一个页面,达到如下语句的效果(即跳转的页面地址并在最后加上?id=**):
int id = (int)DataList1.DataKeys[e.Item.ItemIndex];     //获取当前选中行的行号
if (e.CommandName == "showNews")
{
     try
     {
           Response.Redirect("showNews.aspx?id="+id.ToString());
     }
     catch (Exception ex)
     {
           Response.Write(ex);
     }
}这样的话我要在NavigateUrl怎么写绑定表达式呢???

解决方案 »

  1.   

    假如单个参数,只要DataBinder.Eval(Container.DataItem, "id", "showNews.aspx?id={0}")
      

  2.   

    多个<%# String.Format("shownew.aspx?id={0}&name={1}&misc={1}", DataBinder.Eval(Container.DataItem, "id"), DataBinder.Eval(Container.DataItem, "name"),  DataBinder.Eval(Container.DataItem, "misc")) %>
      

  3.   

    我的id是在DataList的ItemCommand事件中取出来的刚才直接按你上面说的绑出现的问题:
    DataBinding:“System.Data.DataRowView”不包含名为“id”的属性。