int productsum = 0; public string CalTotal(int total) { productsum += total; return total.ToString(); } public string GetSum() { return productsum.ToString(); }
<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 } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)