zoukankan      html  css  js  c++  java
  • 两个DropDownList在DataGrid里,后一个随着前一个改变而改变

    前台代码如下: 

    <asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                            Width="100%" CssClass="colortable">
                                            <FooterStyle CssClass="Table_Foot" />
                                            <EditItemStyle CssClass="Table_Edit" />
                                            <SelectedItemStyle CssClass="Table_Select" />
                                            <PagerStyle CssClass="Table_Page" HorizontalAlign="Center" Visible="False" />
                                            <AlternatingItemStyle CssClass="in3" />
                                            <ItemStyle CssClass="in2" />
                                            <HeaderStyle CssClass="listtop" />
                                            <Columns>
                                                  <asp:TemplateColumn HeaderText="目标舍" ItemStyle-CssClass="checkwidth" HeaderStyle-Width="50">
                                                    <ItemTemplate>
                                                        <asp:DropDownList runat="server" ID="DropDownListHouseID"    OnSelectedIndexChanged="DropDownListHouseID_SelectedIndexChanged"
                                                            AutoPostBack="true">
                                                        </asp:DropDownList>
                                                    </ItemTemplate>
                                                </asp:TemplateColumn>
                                                <asp:TemplateColumn HeaderText="目标栏" ItemStyle-CssClass="checkwidth" HeaderStyle-Width="50">
                                                    <ItemTemplate>
                                                        <asp:DropDownList runat="server" ID="DropDownListHurdle">
                                                        </asp:DropDownList>
                                                    </ItemTemplate>
                                                </asp:TemplateColumn> 

                                                         </Columns>
                                        </asp:DataGrid>

    后台代码如下: 

      protected void DropDownListHouseID_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList dpl = sender as DropDownList;

            object obj = dpl.NamingContainer;
            DataGridItem di = (DataGridItem)dpl.NamingContainer;
            DropDownList dplhurdle = (DropDownList)di.Cells[10].FindControl("DropDownListHurdle");

       
            dplhurdle.DataSource = 数据集

            dplhurdle.DataTextField = ;
            dplhurdle.DataValueField = ;

            dplhurdle.DataBind();
                }

  • 相关阅读:
    接口测试基础理论
    Python 接口测试requests.post方法中data与json参数区别
    将博客搬至CSDN
    [设计模式] 设计模式课程(二十)--命令模式(Command)
    [设计模式] 设计模式课程(十三)-- 代理模式
    [设计模式] 设计模式课程(十一)-- 享元模式(Flyweight)
    [设计模式] 设计模式课程(十二)-- 门面模式(Facade)
    [设计模式] 设计模式课程(十七)--组合模式
    [设计模式] 设计模式课程(六)-- 桥接模式
    [设计模式] 读懂UML图
  • 原文地址:https://www.cnblogs.com/saimisei/p/1255696.html
Copyright © 2011-2022 走看看