<asp:TextBox id="tb1" runat="server" text="<%#var%>" />
在*.cs文件里声称
public string var="admin";
Page.DataBind();

解决方案 »

  1.   

    不行
    我是
    <asp:ListItem Value="main.aspx<%# var%>">测试</asp:ListItem>
      

  2.   

    try : Value="main.aspx<%#=var%>" 
    var in code-behind declared as public.
      

  3.   

    还是失败
    我感觉象这种listitem是checkboxlist之类的属性
    可能它在load之前就已经处理了
      

  4.   

    AutoPostBack 的属性是否要设为 true
      

  5.   

    这个和AutoPostBack 没有多大关系吧
    而且我也不需要autopost
    我只是一个checkboxlist
    然后直接在设计界面上加了listitem
    只不过这些listitem的一部份值是会变的
    如果全部用用语句一个个来add是可以的
    我只不过想让它在设计界面上直接加listitem
    然后通过绑定改变一部份值而已
      

  6.   

    so try this method:
    <asp:ListItem Value='<%# GetVar()%>'>测试</asp:ListItem>take main.aspx into a function together.in code-behind,try
    public string GetVar(0
    {
    var=...;
    return "main.aspx"+var;
    }