<a href='<%# "teacher_show_teach.aspx?id="+show_id() %>'>教学课程</a>you can do that, as long as you call Page.DataBind() in your Page_Load or somewhere

解决方案 »

  1.   

    同意saucer(思归, MS .NET MVP)
      

  2.   

    Why Not?<a href='teacher_show_teach.aspx?id=<% show_id() %>'>教学课程</a>
      

  3.   

    呵呵,谢谢二位,我在.cs中是这样写的
    pageload()
    {
    show_id();
    }
    public string show_id()
    {
        return ViewState["id"].ToString();
    }
    只是简单的返回id值,可能错的比较笨了,小弟初学,还请多多关照!
      

  4.   

    <a href='<%# "teacher_show_teach.aspx?id="+show_id() %>'>教学课程</a>
    <script language="C#" runat="server">
    public string show_id()
    {
       //请确认ViewState["id"] != null
        return ViewState["id"].ToString();
    }
    void Page_Load (Object o, EventArgs e)
    {
     Page.DataBind();
    }
      

  5.   

    哈哈,谢谢思归大哥,已经搞定。好像我犯的错误是:在调用绑定的时候,没有处理对数据的绑定。如果要是datagrid或者datalist时,我会用datagrid.DataBind();
    但不知Page代表何意呀?
    呵呵,多学点东西了,呵呵
    麻烦再解释一下了!
      

  6.   

    DataBind() is System.Web.UI.Control's method, it is for databinding, i.e., if you call DataBind() on an object, all the code in its scope like
    <%# ..%>will be executed. Page and those webcontrols are directly or indirectly derived from Control if you used
    <a href='<%= "teacher_show_teach.aspx?id="+show_id() %>'>教学课程</a>then you don't need to call Page.DataBind()