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;

    }

  • 相关阅读:
    适配iOS 10以及Xcode 8(转载)
    React-nwb的使用
    Android与JS混编(多图选择器)
    Android与JS混编(js调用android相机扫描二维码)
    Android与JS混编(js调用android相机)
    iOS: FFmpeg的使用
    UITableView/UICollectionView使用技巧
    IOS MapKit框架的使用(专门用于地图显示)
    iOS 地理编码 / 反地理编码
    iOS地图 -- 定位使用
  • 原文地址:https://www.cnblogs.com/qfb620/p/2057163.html
Copyright © 2011-2022 走看看