本文介绍了嗨伙计。请帮忙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Checkbox1的gridview,其余的是列,但重要的是 Amount Column.if我选中了3个复选框,它必须根据选中的复选框计算Amount。任何想法请帮助
我尝试过的事情:
我的gridview
I'm having gridview with one Checkbox1 and the rest is columns, but the vital one is Amount Column.if I checked 3 checkboxes it must calculate Amount based on checked checkboxes. Any ideas please help
What I have tried:
My gridview
<asp:GridView ID="GridView2" runat="server" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing" OnRowCommand="GridView1_RowCommand" OnRowUpdating="GridView1_RowUpdating" DataKeyNames="CallID" AutoGenerateColumns="False" Width="1342px" ShowFooter="True" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowCreated="GridView1_RowCreated" style="margin-top: 0px" OnRowDataBound="GridView2_RowDataBound">
<columns>
<asp:templatefield headertext="">
<itemtemplate>
<asp:CheckBox ID="CheckBox2" runat="server">
</itemtemplate>
<asp:TemplateField HeaderText="Company name" Visible="False">
<itemtemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Eval("CallID") %>'>
<br />
</itemtemplate>
<edititemtemplate>
<asp:TextBox ID="txtCompanyName" runat="server" Text=' <%# Eval("CallID") %>'>
<asp:RadioButton ID ="txtyes" runat ="server" Text ="" />
</edititemtemplate>
<asp:TemplateField HeaderText="NewNam">
<itemtemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Eval("NewNam") %>'>
</itemtemplate>
<edititemtemplate>
<asp:TextBox ID="txtCompanyName" runat="server" Text=' <%# Eval("NewNam") %>'>
</edititemtemplate>
<asp:TemplateField HeaderText="Called No">
<itemtemplate>
<asp:Label ID="Label61" runat="server" Text='<%# Eval("CalledNo") %>'>
</itemtemplate>
<edititemtemplate>
<asp:TextBox ID="txtCompanyName" runat="server" Text=' <%# Eval("CalledNo") %>'>
</edititemtemplate>
<asp:TemplateField HeaderText="Call Extension">
<itemtemplate>
<asp:Label ID="Label51" runat="server" Text='<%# Eval("CallExt") %>'>
</itemtemplate>
<edititemtemplate>
<asp:TextBox ID="txtPostalAddress" runat="server" Text=' <%# Eval("CallExt") %>'>
</edititemtemplate>
<asp:TemplateField HeaderText="Call Duration">
<itemtemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Eval("CallDuration") %>'>
</itemtemplate>
<edititemtemplate>
<asp:TextBox ID="txtResidentialAddress" runat="server" Text=' <%# Eval("CallDuration") %>'>
</edititemtemplate>
<asp:TemplateField HeaderText="Amount">
<itemtemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Eval("Amount") %>'>
</itemtemplate>
<edititemtemplate>
<asp:TextBox ID="txtWebSite" runat="server" Text=' <%# Eval("Amount") %>'>
</edititemtemplate>
<asp:TemplateField HeaderText="tmpNewNam" Visible="False">
<itemtemplate>
<asp:Label ID="Label50" runat="server" Text='<%# Eval("tmpNewNam") %>'>
</itemtemplate>
<edititemtemplate>
<asp:TextBox ID="txtIfOtherSpecify" runat="server" Text=' <%# Eval("tmpNewNam") %>'>
</edititemtemplate>
</columns>
<emptydatatemplate>
<asp:RadioButton ID="RadioButton1" runat="server" />
<asp:RadioButton ID="RadioButton2" runat="server" />
<br />
</emptydatatemplate>
<HeaderStyle BackColor="#00274F" ForeColor="White" />
Code Behind on button click
double sum = 0;
foreach (GridViewRow gvr in GridView2.Rows)
{
CheckBox cb = (CheckBox)gvr.FindControl("CheckBox2");
if (cb.Checked)
{
double amount = Convert.ToDouble(gvr.Cells[6].Text.Replace(" ", ""));
sum += amount;
}
txtbusiness.Text = sum.ToString();
}
}
错误,我是获取
输入字符串的格式不正确。
请帮忙。在此先感谢
Error that i'm getting
Input string was not in a correct format.
Please help. Thanks in advance
推荐答案
这篇关于嗨伙计。请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!