GridView下DropDownList 的选择方法onselectedindexchanged 实现方法
来源:互联网 发布:sql 循环select结果集 编辑:程序博客网 时间:2024/06/07 17:12
在GridView下面绑定好了下拉框,我们常常会遇到一个问题,
选择方法怎么实现呢,用js总是难的去算是在GridView的第几行第几个元素,因为服务器的id和客户端的id经常变化让js根本无从找起,所以我认为还是用DropnLIst的自带选择方法实现是最佳的。
下面是前端代码,要注意一点AutoPostBack一定要设为true,不然就不实现后台方法了。
<asp:DropDownList ID="dddjfoot" runat="server" AppendDataBoundItems="true"
AutoPostBack="true" onselectedindexchanged="dddjfoot_SelectedIndexChanged">
<asp:ListItem Value=" ">-请选择-</asp:ListItem>
<asp:ListItem Value="厂价">厂价</asp:ListItem>
<asp:ListItem Value="优价">优价</asp:ListItem>
<asp:ListItem Value="批发价">批发价</asp:ListItem>
<asp:ListItem Value="优惠价">优惠价</asp:ListItem>
<asp:ListItem Value="面议">面议</asp:ListItem>
</asp:DropDownList>
后台代码
protected void dddjitem_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
GridViewRow row = (GridViewRow)ddl.Parent.Parent;
TextBox tb = row.FindControl("txtdj") as TextBox;
tb.Text = ddl.SelectedValue;
}
GridViewRow row = (GridViewRow)ddl.Parent.Parent;这句是获取当前选择行,获取这行数据基本上就能取到本行的所以值,并且能对当前行所有控件进行操作了。
- GridView下DropDownList 的选择方法onselectedindexchanged 实现方法
- GridView 的 onselectedindexchanged 方法
- 向GridView中DropDownList控制项添加OnSelectedIndexChanged实现级联动 (转)
- dropdownlist无法执行onselectedindexchanged的问题
- C#下实现主从DropDownList互动的方法
- C#下实现主从DropDownList互动的方法(转)
- C#下实现主从DropDownList互动的方法
- C#下实现主从DropDownList互动的方法
- .net实例:C#下实现主从DropDownList互动的方法
- 实现GridView选择行突出显示的方法
- GridView 的DropDownList分页实现
- GridView 的DropDownList分页实现
- DropDownList中OnSelectedIndexChanged问题
- DropDownList的无刷新实现方法
- 固定GridView表头方法的选择
- asp.net下gridview 批量删除的实现方法
- dropdownlist的FindByValue方法
- DropDownList的FindByText方法
- KVM桥接网络设置
- js 整理
- Cache-Control
- uu-aodv框架分析
- 破解软件,破解技术最高价值。
- GridView下DropDownList 的选择方法onselectedindexchanged 实现方法
- DM816x RDK MultiCh_Demo MultiCh_createVcapVdis
- 数据库设计中的14个技巧
- Java 小例子:读取控制台的用户输入
- 自定义Struts2类型转换器
- POJ 3083
- 各类报头TCP/UDP/ICMP/IP结构
- MapX的一些注意事项
- 解决ora-01861文字与格式字符串不匹配