有一个DropDownList,一个asp:Linkbutton
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            onselectedindexchanged="DropDownList2_SelectedIndexChanged">
            <asp:ListItem Value="1">1</asp:ListItem>
            <asp:ListItem Value="2">2</asp:ListItem>
            <asp:ListItem Value="3">3</asp:ListItem>
        </asp:DropDownList>        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                Enabled='<%# DropDownList2.SelectedIndex!=0 %>'>首页</asp:LinkButton>现在想要LinkButton的Enabled用服务器端标记<%# DropDownList2.SelectedIndex!=0 %>来判断,可是老是不能让LinkButton的属性变化,请高手帮忙

解决方案 »

  1.   

    DropDownList2_SelectedIndexChanged中设置LinkButton 
    或通过onchange设置
      

  2.   

    我的意思是能不能像GridView自定义PagerTemplate中
    <asp:LinkButton ID="btnFirst" runat="server" CausesValidation="False" CommandArgument="First" CommandName="Page" Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>" Text="首页"></asp:LinkButton>这样去用DownLoadList控制linkbutton的enable
      

  3.   

    Enabled="<%# GetEnable(Container.NamingContainer)%>"
    public bool GetEnable(..
      

  4.   

    还是不行,我这样写的    
    后台
    public bool getenable(DropDownList dl)
        {
            if (dl.SelectedIndex == 0)
                return false;
            else
                return true;
        }
    前台
         <asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True">
             <asp:ListItem Selected="True">1</asp:ListItem>
             <asp:ListItem>2</asp:ListItem>
             <asp:ListItem>3</asp:ListItem>
        </asp:DropDownList>
        <asp:LinkButton ID="LinkButton5" runat="server" Enabled="<%# getenable(DropDownList3)%>">LinkButton</asp:LinkButton>