如何为GridView中的子控件设置条件 [英] how to put a condition to a child control which is in gridview

查看:60
本文介绍了如何为GridView中的子控件设置条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi

点击按钮后,我想重定向到另一个页面仅当checkbox.checked.here是我的.aspx和aspx.cs

hi

i want to redirect to another page when button is clicked & only if the checkbox.checked.here is my .aspx and aspx.cs

<%@ Page Language="C#" MasterPageFile="~/HostMasterPage.master" AutoEventWireup="true"CodeFile="~/DomainHomePageN.aspx.cs" Inherits="DomainHomePageN" Title="Web hosting in India,web hosting  hyderabad" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table>
        <tr>
            <td align="center" valign="bottom">
                <table width="980" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff"class="border"><tr>
 <td align="center" valign="top" bgcolor="#ffffff" style="height: 20px;">
 </td></tr> <tr>
  <td align="left" style="padding-left: 100px;">
   <table style="font-family: Verdana; font-size: 12px; width: 400px;" cellpadding="0"cellspacing="0"><tr>
 <td style="width: 421px;">
 <asp:GridView ID="gvNotAvail" runat="server" Caption="Not Available" Width="300px" CaptionAlign="left" GridLines="None" ShowHeader="false" AutoGenerateColumns="false"CellPadding="3" CellSpacing="3">
<Columns>
 <asp:BoundField DataField="domain" HeaderText="Domain" />
 </Columns>
 </asp:GridView>
 </td> </tr> <tr>
 <td style="height: 30px;"></td> </tr> <tr>
<td align="center" style="border-width: 1px; border-color: #cacaca; border-bottom-color: #cacaca;
 width: 421px;">
<div style='color: #996699; font-weight: bold; font-size: 16px;'>
<table style="width: 522px;" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 25px; width: 232px;" class="style2" align="left">
<img height="13" src="images/getImage[8].gif" width="13" />Available (Domains)
</td></tr></table>
</div>
<div style="overflow: scroll; overflow-x: hidden; height: 130px; border: solid 2px #cacaca;
scrollbar-face-color: #cacaca; scrollbar-highlight-color: #cacaca; scrollbar-3dlight-color: #cacaca;
scrollbar-darkshadow-color: #cacaca; scrollbar-shadow-color: #cacaca; scrollbar-arrow-color: #000000;
scrollbar-track-color: #ffffff;">
<br />
<asp:GridView ID="gvAvail" Width="500px" CssClass="tableView" runat="server" ShowHeader="False"ShowFooter="True" GridLines="None" AutoGenerateColumns="False" CellPadding="4"CellSpacing="1" AllowSorting="True">
<Columns>
<asp:TemplateField>
<%--<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("selected") %>' />
</EditItemTemplate>--%>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("selected") %>' Enabled="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="domain" HeaderText="Domain">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
 <asp:TemplateField HeaderText="Price" ItemStyle-VerticalAlign="Top">
  <%--<EditItemTemplate>
   <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("price") %>'></asp:TextBox></EditItemTemplate>--%>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<ItemTemplate>
 <img src="images/rupeesymbol.jpg" alt="" />
<asp:Label ID="Label1" runat="server" Text='<%# Bind("price") %>'></asp:Label> /-
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle HorizontalAlign="Left" />
<FooterStyle HorizontalAlign="Left" />
<AlternatingRowStyle BackColor="WhiteSmoke" Wrap="True" />
 </asp:GridView>
</div>
</td>
</tr>
<tr>
<td align="center">
<br />
<asp:Button ID="btnAddcart" runat="server" Text="Add To Cart" Font-Bold="True" Font-Names="Verdana"Font-Size="Medium" Height="36px" OnClick="btnAddcart_Click" Width="128px" />
<asp:HiddenField ID="hidden" runat="server" />
<asp:TextBox ID="txttotal" runat="server"></asp:TextBox>
</td>
</tr>
</table>


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js">
    </script>
    <script type="text/javascript">
        $(function () {
            //Column index value of price field (Column index start from 1)
            var columnIndexValue = 3;

            var checked = $('input:checkbox').click(function (e) {

                var total = 0;
                $("tr:has(:checkbox:checked) td:nth-child(" + columnIndexValue + ")").each(function () {
                    total += parseInt($(this).text());
                });

                $('#hidden').val(total.toFixed());


            });

        });


 </script>


</asp:Content







protected void btnAddcart_Click(object sender, EventArgs e)
   {
       Session["Dtotal"] = hidden.Value;
       Response.Redirect("CustSignUpPage.aspx");
       //txttotal.Text = Session["Dtotal"].ToString();
   }

推荐答案

(function(){ //价格字段的列索引值(列索引从1开始) var columnIndexValue = 3; varchecked =
(function () { //Column index value of price field (Column index start from 1) var columnIndexValue = 3; var checked =


('input:checkbox').click(function(e){ var total = 0;
('input:checkbox').click(function (e) { var total = 0;


("tr:has(:checkbox:checked)td:nth-​​child(" + columnIndexValue +)").each(function(){ 总计+ = parseInt(
("tr:has(:checkbox:checked) td:nth-child(" + columnIndexValue + ")").each(function () { total += parseInt(


这篇关于如何为GridView中的子控件设置条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆