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;

    }

  • 相关阅读:
    OCP 062【中文】考试题库(cuug内部资料)第19题
    OCP 062【中文】考试题库(cuug内部资料)第18题
    OCP 062【中文】考试题库(cuug内部资料)第17题
    743. 网络延迟时间 力扣(中等) 最短路径SPFA,不熟练
    1337. 矩阵中战斗力最弱的 K 行 力扣(简单) 确实简单,结构体排序,二分也可
    171. Excel 表列序号 力扣(简单) 想不明白的题
    987. 二叉树的垂序遍历 力扣(困难) bfs+hash+优先队列 感觉还是简单的,就是复杂了点
    46. 全排列 力扣(中等) 容器或回溯
    1947. 最大兼容性评分和 周赛 力扣(中等) 排列next_permutation用法
    1104. 二叉树寻路 力扣(中等) 数学题,思考久了
  • 原文地址:https://www.cnblogs.com/qfb620/p/2057163.html
Copyright © 2011-2022 走看看