GridView中两个DropDownList联动

http://www.cnblogs.com/qfb620/archive/2011/05/25/2057163.html

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;

}

 
 

GridView中两个DropDownList联动的更多相关文章

  1. MVC编辑状态两个DropDownList联动

    前几天使用jQuery在MVC应用程序中,实现了<jQuery实现两个DropDownList联动(MVC)>http://www.cnblogs.com/insus/p/3414480. ...

  2. jQuery实现两个DropDownList联动(MVC)

    近段时间原本是学习MVC的,谁知道把jQuery也学上了.而且觉得对jQuery更感兴趣,比如今早上有写了一个练习<jQuery实现DropDownList(MVC)>http://www ...

  3. 两个dropDownList和一个GridView的选择与显示

    很久没有写ASP.NET了,今天有看到论坛上一个问题:"两个dropDownList和一个GridView,已经进行了数据绑定,现在想让第一个下拉菜单的数据改变时,第二个下拉菜单自动变到相应 ...

  4. Js获取Gridview中Dropdownlist选中状态

    在Gridview中加入Dropdownlist模板列,加入DropDownlist 是一种常用的操作,其中涉及到如何获取选择项和Gridview重新绑定两个要点. 如图 前台代码如下 <%@ ...

  5. GridView 中绑定DropDownList ,下拉框默认选中Label的值

    在GridView中,我们 有时候要绑定值. 前台绑定的代码可以这样 <asp:TemplateField HeaderText="当前状态" ItemStyle-Horiz ...

  6. DEV控件中GridView中的复选框与CheckBox实现联动的全选功能

    最初的界面图如图1-1(全选框ID: cb_checkall  DEV控件名称:gcCon ): 要实现的功能如下图(1-2  1-3  1-4)及代码所示: 图1-2 图1-3 图1-4 O(∩_∩ ...

  7. Gridview中Datakeys 通过主键取得各列的值。

    首先在初始化Gridview时候定义主键的数组. GridViewTeacherStudent.DataKeyNames=new string[] {"courseId",&quo ...

  8. asp.net中父子页面通过gridview中的按钮事件进行回传值的问题

    这两天写BS程序,遇到父子页面传值的问题,以前没写过web系统,用了几天时间才将问题解决,总结下记录下来: 问题描述: 父页面A中有一个gridview,每行6个列,有5列中均有一个按钮,单击按钮,会 ...

  9. GridView中的超级链接技巧

    GridView中的超级链接,可以设置一个模版列,放入超级链接的控件,设置绑定参数即可. 数据绑定方式有两种,如下示例: Eval方式 <%# Eval("id") %> ...

随机推荐

  1. Android Push Notifications using Google Cloud Messaging (GCM), PHP and MySQL

    http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php- ...

  2. 【日报C在23】堆和栈的深入了解

    每日一C之堆与栈的深入理解        每天拾一个C语言贝壳,厚积薄发,积跬步以致千里.  今日贝壳:内存中堆与栈的深入理解.认识一个清晰地内存                          假 ...

  3. react.js 从零开始(六)Reconciliation

    Reconciliation   React 的关键设计目标是使 API 看起来就像每一次有数据更新的时候,整个应用重新渲染了一样.这就极大地简化了应用的编写,但是同时使 React 易于驾驭,也是一 ...

  4. 产品 线上 保持 和 支持 服务 (Support and maintenance solutions)

    Maintenance and support are the key factors for the smooth functioning of ERP solutions. ERP mainten ...

  5. Flex列在一个表格式的数字值

    1.问题背景 一般的.表格中展示的比率.对照率的处理是:保留两位小数,并向上保留 2.实现实例 <? xml version="1.0" encoding="utf ...

  6. 【Flume NG用户指南】(2)构造

    作者:周邦涛(Timen) Email:zhoubangtao@gmail.com 转载请注明出处:  http://blog.csdn.net/zhoubangtao/article/details ...

  7. 2014辛星完全解读html第五节

    员,那么肯定会知道什么叫表单,这里我们就介绍一下前台怎样使用表单.表单的使用也是我们编写网页的必须经历的一关.并且,表单也往往是我们站点的漏洞和弱点出现的地方. *************表单**** ...

  8. C++ 在dynamic_cast&lt;&gt;用法

    /*这是从网上断开的试样.主要是关于 dynamic_cast<> 用法.*/ /* 行动:对象指向一个基类(或参考)cast一个指向派生类,dynamic_cast将基于一个基类指针确实 ...

  9. Compare .NET Objects对象比较组件

    Compare .NET Objects对象比较组件 阅读目录 1.Compare .NET Objects介绍 2. Compare .NET Objects注意事项 3.一个简单的使用案例 4.三 ...

  10. c#中 ==与equals有什么区别

    对于值类型.引用类型来说比较过程怎样的? using System;using System.Collections.Generic;using System.Text; namespace Cons ...