此代码汇总了列Должи中的所有单元格。我想只勾选带复选框的已检查单元格。怎么做? [英] This code sum all cells in column Должи. I want to sum only checked cells with checkbox. How to do that?
本文介绍了此代码汇总了列Должи中的所有单元格。我想只勾选带复选框的已检查单元格。怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int productsum = 0;
public string CalTotal(int total)
{
productsum += total;
return total.ToString();
}
public string GetSum()
{
return productsum.ToString();
}
带有复选框的GridView1的Aspx代码。我想只获取已检查的单元格并将其传递到另一页
Aspx code for GridView1 with checkbox. I want to get only checked cells and pass it to another page
<asp:GridView ID="GridView1" ShowFooter="true" OnRowDataBound="GridView1_RowDataBound" runat="server" AutoGenerateColumns="False" DataKeyNames="korisnikID" DataSourceID="SqlDataSource1" Height="320px" Width="763px" CellPadding="4" Font-Names="Calibri" ForeColor="#333333" HorizontalAlign="Center" font-size="Medium" GridLines="None" CssClass="auto-style9" >
<Columns>
<asp:BoundField DataField="fakturaID" HeaderText="Број на сметка" InsertVisible="true" ReadOnly="True" SortExpression="fakturaID" HeaderStyle-Width="100px"/>
<asp:BoundField DataField="korisnikID" HeaderText="korisnikID" SortExpression="korisnikID" Visible="False" />
<asp:BoundField DataField="ЗаПериод" HeaderText="За период" SortExpression="ЗаПериод" DataFormatString="{0:dd-MMM-yyyy}" HeaderStyle-Width="100px"/>
<asp:TemplateField HeaderText="Износ" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="lbliznos" runat="server" Text='<%# Eval("Износ")%>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ДатумНаПлаќање" HeaderText="Датум на плаќање" SortExpression="ДатумНаПлаќање" DataFormatString="{0:dd-MMM-yyyy}" HeaderStyle-Width="100px" />
<asp:TemplateField HeaderText="Побарува" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="lblpobaruva" runat="server" Text='<%# Eval("Побарува")%>'/>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="Label2" runat="server" Text="Вкупно сума за плаќање"></asp:Label>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Должи" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="lblListPrice" runat="server" Text='<%#CalTotal(int.Parse(Eval("Должи").ToString()))%>'/>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="lblTotal" runat="server" Text='<%# GetSum() %>'/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Означи за плаќање">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" onclick="javascript: DisableButton()"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
推荐答案
int count = gvPurchaseEntry.Rows.Count;
for (i = 0; i < count; i++)
{
CheckBox chk= (CheckBox )gvPurchaseEntry.Rows[i].FindControl("CheckBox1");
if(chk.Checked==true)
{
your code
}
}
这篇关于此代码汇总了列Должи中的所有单元格。我想只勾选带复选框的已检查单元格。怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文