<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" >
<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='<%# int.Parse(Eval("Должи").ToString())%>'/> </Label> </ItemTemplate> <FooterTemplate> <asp:Label ID="lblTotal" runat="server" Text=""></asp:Label> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Означи за плаќање"> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" onclick="javascript: DisableButton()"/> </ItemTemplate> </asp:TemplateField> </Columns>
protected void Button2_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("Корисник", typeof(string)); dt.Columns.Add("Износ", typeof(int)); dt.Columns.Add("Побарува", typeof(int)); dt.Columns.Add("Должи", typeof(int)); SqlConnection sqlConn = new SqlConnection(Web.GetConfigValue("proekt1")); CheckBox ch; string fakturi = ""; foreach (GridViewRow row in GridView1.Rows) { int n = row.RowIndex; ch = (CheckBox)row.FindControl("CheckBox1"); if (ch.Checked == true) { Label lblCol1 = row.FindControl("lbliznos") as Label; Label lblCol2 = row.FindControl("lblpobaruva") as Label; Label lblCol3 = row.FindControl("lblListPrice") as Label; if (lblCol1 != null && lblCol2 != null && lblCol3 != null) { int val1 = int.Parse(lblCol1.Text); int val2 = int.Parse(lblCol2.Text); int val3 = int.Parse(lblCol3.Text); lblCol2.Text = (val2 + val3).ToString(); lblCol3.Text = (val3 * 0).ToString(); } DataRow r = dt.NewRow(); r["Корисник"] = Web.SessionUser.Naziv.ToString(); //row.Cells[1].Text; Label name2 = (Label)GridView1.Rows[n].Cells[3].FindControl("lbliznos"); r["Износ"] = name2.Text; Label name = (Label)GridView1.Rows[n].Cells[5].FindControl("lblpobaruva"); r["Побарува"] = name.Text; Label name1 = (Label)GridView1.Rows[n].Cells[6].FindControl("lblListPrice"); r["Должи"] = name1.Text; if (fakturi != "") fakturi += ","; fakturi += row.Cells[0].Text; dt.Rows.Add(r); } } Session["platiltabela"] = dt; Session["fakturi"] = fakturi; Response.Redirect("Naplata.aspx"); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { CheckBox chk = (CheckBox)e.Row.FindControl("CheckBox1"); Label name1 = (Label)e.Row.FindControl("lblListPrice"); if (name1.Text == "0") { chk.Enabled = false; } else { chk.Enabled = true; } if (chk.Checked == false) { Button2.Enabled = false; } else { Button2.Enabled = true; } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)