zoukankan      html  css  js  c++  java
  • GridView中两个DropDownList联动

    Html:

    <asp:UpdatePanel runat="server" ID="AccountUpdate" UpdateMode="Conditional"  >
                            <ContentTemplate>
                            <asp:GridView ID="gridAccount" runat="server" Width="100%" AutoGenerateColumns="False">
                                <Columns>

                                    <asp:TemplateField HeaderText="选择一" ItemStyle-Width="15%">
                                        <ItemTemplate>
                                        <asp:DropDownList ID="ddlA" OnSelectedIndexChanged="ddlA_SelectedIndexChanged" AutoPostBack="true" runat="server" Width="50px">
                                        <asp:ListItem Value="">全部</asp:ListItem>
                                        <asp:ListItem Value="1">是</asp:ListItem>
                                        <asp:ListItem Value="0">否</asp:ListItem>
                                    </asp:DropDownList>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="选择二" ItemStyle-Width="15%">
                                        <ItemTemplate>
                                        <asp:DropDownList ID="ddlB" runat="server" Width="50px">
                                        <asp:ListItem Value="">全部</asp:ListItem>
                                        <asp:ListItem Value="1">是</asp:ListItem>
                                        <asp:ListItem Value="0">否</asp:ListItem>
                                    </asp:DropDownList>
                                        </ItemTemplate>
                                    </asp:TemplateField>

    </Columns>
                           </asp:GridView>
                            </ContentTemplate>
                            </asp:UpdatePanel>

    CS:

    public void ddlA_SelectedIndexChanged(object sender, EventArgs e)
            {

     DropDownList ddlA= (DropDownList)sender;//获取现在的事件触发者:

                GridViewRow gvr = (GridViewRow)ddlA.NamingContainer;//ddlA同属于在一个NamingContainer下

                DropDownList ddlB= (DropDownList)gvr.FindControl("ddlB");//找到ddlA的DropDownList

                ddlB.Enabled = false;

    }

  • 相关阅读:
    【作业4】测试作业-兴趣问题清单
    【读后感3】高效程序员的45个习惯
    【作业3】关于C语言的问卷调查
    【作业2】价值观作业
    Spring的零配置
    Spring容器中bean的作用域
    Spring注入方式
    Spring整合Struts2
    my first go
    Struts2对ajax的支持
  • 原文地址:https://www.cnblogs.com/qfb620/p/2057163.html
Copyright © 2011-2022 走看看