GridView嵌套DropDownList联动问题
来源:互联网 发布:天刀真武捏脸数据下载 编辑:程序博客网 时间:2024/06/05 00:16
今天需要做一个如下所示的功能,对单品进行折扣操作。需要在GridView中嵌入DropDownList来实现。
实现方法:
前台代码
<asp:TemplateField HeaderText="折扣">
<ItemTemplate>
<asp:DropDownList ID="drop_zhekou" runat="server"AutoPostBack="true" OnSelectedIndexChanged="drop_zhekou_selected_changed">
<asp:ListItem Text="無折扣" Value="1"></asp:ListItem>
<asp:ListItem Text="9.5折" Value="0.95"></asp:ListItem>
<asp:ListItem Text="9折" Value="0.9"></asp:ListItem>
<asp:ListItem Text="8.5折" Value="0.85"></asp:ListItem>
<asp:ListItem Text="8折" Value="0.8"></asp:ListItem>
<asp:ListItem Text="7折" Value="0.7"></asp:ListItem>
<asp:ListItem Text="6折" Value="0.6"></asp:ListItem>
<asp:ListItem Text="5折" Value="0.5"></asp:ListItem>
<asp:ListItem Text="4折" Value="0.4"></asp:ListItem>
<asp:ListItem Text="3折" Value="0.3"></asp:ListItem>
</asp:DropDownList>
折後價格:<asp:Label ID="lbl_zhehoujia" runat="server" ForeColor="Green"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
后台代码:
protected void drop_zhekou_selected_changed(object sender, EventArgs e) { DropDownList drop = sender as DropDownList; GridViewRow row = drop.Parent.Parent as GridViewRow; decimal zj = Convert.ToDecimal(row.Cells[4].Text);//获取单品总价 decimal zk = Convert.ToDecimal(drop.SelectedValue);//获取折扣值 ((Label)row.Cells[5].FindControl("lbl_zhehoujia")).Text = (zj*zk).ToString();//计算折后价并赋值 getSumprice();//重新计算支付总额 }
- GridView嵌套DropDownList联动问题
- GridView中多个DropDownList的联动问题
- gridview中连个dropdownlist联动
- GridView中DropDownList联动
- gridview嵌套DropDownList選定值
- DropDownList+GridView三级联动效果
- GridView编辑状态下DropDownList的联动
- C# DropDownList二级联动问题
- gridview--嵌套dropdownlist 然后更新列
- GridView 中嵌套DropDownList时的事件
- asp.net:gridview 中嵌套dropdownlist,且dropdownlist動態綁定數據
- GridView中DropdownList,Textbox同一行无刷新联动
- Gridview与DropDownList联动添加数据实时更新
- ListView嵌套GridView问题
- dropdownlist联动
- asp.net 2.0中gridview里嵌套dropdownlist
- asp.net 2.0中gridview里嵌套dropdownlist
- asp.net 2.0中gridview里嵌套dropdownlist
- Ubuntu安装配置MySQL
- 内存屏障(memory barrier)
- 服务器公共组件实现 -- 状态机
- 如何在SSH断开后让远程服务器程序继续运行
- orcale 中varchar2 和nvarchar2的区别
- GridView嵌套DropDownList联动问题
- 线程----BlockingQueue (转)
- XML简单操作类、只可操作单行数据(可直接使用)
- ContentProvider的用法
- 数据持久化辅助类
- 服务器公共组件 -- 事件与信号
- JS 字符串操作,用的时候看看
- 委差的含义
- 复合服务 Composite Services