예제 #1
0
    protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            QtyTotal = 0;

            if (txtCommodity.Text == "Gunny")
            {
                e.Row.Cells[3].Text = "परिवहन की मात्रा (Bales)";
            }
            else
            {
                e.Row.Cells[3].Text = "परिवहन की मात्रा (मै० टन)";
            }
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Text = (e.Row.RowIndex + 1).ToString();

            ConvertQtlsToMT = 0;
            ConvertQtlsToMT = ((double.Parse(e.Row.Cells[3].Text)));
            QtyTotalSubMO  += ConvertQtlsToMT;
        }

        if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[2].Text = "कुल मात्रा";
            e.Row.Cells[3].Text = QtyTotalSubMO.ToString("0.00");

            RowSpan = 1;
            ro      = 0;
            int j = 0;
            for (int i = 0; i < GridView2.Rows.Count - 1; i++)
            {
                GridViewRow currrow = GridView2.Rows[j];
                GridViewRow nextrow = GridView2.Rows[i + 1];
                if (currrow.Cells[1].Text == nextrow.Cells[1].Text)
                {
                    nextrow.Cells[1].Visible = false;
                    RowSpan += 1;
                    ro++;
                }
                else
                {
                    currrow.Cells[1].RowSpan = RowSpan;
                    RowSpan = 1;
                    j       = i + 1;
                }
            }

            GridViewRow currrow1 = GridView2.Rows[j];
            currrow1.Cells[1].RowSpan = RowSpan;
        }
    }
    protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            QtyTotal = 0;

            if (lblComdty.Text == "Gunny")
            {
                e.Row.Cells[3].Text = "परिवहन की मात्रा (Bales)";
            }
            else
            {
                e.Row.Cells[3].Text = "परिवहन की मात्रा (मै० टन)";
            }
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Text = (e.Row.RowIndex + 1).ToString();

            ConvertQtlsToMT = 0;
            ConvertQtlsToMT = ((double.Parse(e.Row.Cells[3].Text)));
            QtyTotalSubMO  += ConvertQtlsToMT;
        }

        if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[2].Text = "महायोग ";
            e.Row.Cells[3].Text = QtyTotalSubMO.ToString("0.00");

            RowSpan = 1;
            ro      = 0;
            int    j      = 0;
            int    z      = 1;
            double kulyog = 0;
            for (int i = 0; i < GridView2.Rows.Count - 1; i++)
            {
                GridViewRow currrow = GridView2.Rows[j];
                GridViewRow nextrow = GridView2.Rows[i + 1];
                if (currrow.Cells[1].Text == nextrow.Cells[1].Text)
                {
                    nextrow.Cells[1].Visible = false;
                    RowSpan += 1;
                    ro++;
                    GridView2.Rows[j].Cells[0].Text     = "1";
                    GridView2.Rows[i + 1].Cells[0].Text = RowSpan.ToString();
                    kulyog += (double.Parse(GridView2.Rows[i].Cells[3].Text));
                }
                else
                {
                    RowSpan++;
                    currrow.Cells[1].RowSpan = RowSpan;
                    z++;
                    kulyog += (double.Parse(GridView2.Rows[i].Cells[3].Text));
                    GridViewRow     oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
                    TableHeaderCell oTableCell   = new TableHeaderCell();
                    oGridViewRow.Cells.Add(oTableCell);
                    oTableCell                 = new TableHeaderCell();
                    oTableCell.Text            = "कुल योग";
                    oTableCell.ForeColor       = System.Drawing.Color.Red;
                    oTableCell.HorizontalAlign = HorizontalAlign.Right;
                    oGridViewRow.Cells.Add(oTableCell);
                    oTableCell                 = new TableHeaderCell();
                    oTableCell.Text            = kulyog.ToString("0.00");
                    oTableCell.ForeColor       = System.Drawing.Color.Red;
                    oTableCell.HorizontalAlign = HorizontalAlign.Right;
                    oGridViewRow.Cells.Add(oTableCell);
                    int x = (i + z);
                    GridView2.Controls[0].Controls.AddAt(x, oGridViewRow);
                    RowSpan = 1;
                    j       = i + 1;
                    kulyog  = 0;
                }
            }

            kulyog += (double.Parse(GridView2.Rows[GridView2.Rows.Count - 1].Cells[3].Text));
            GridViewRow currrow1 = GridView2.Rows[j];
            currrow1.Cells[1].RowSpan = RowSpan + 1;
            GridViewRow     oGridViewRow1 = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
            TableHeaderCell oTableCell1   = new TableHeaderCell();
            oGridViewRow1.Cells.Add(oTableCell1);
            oTableCell1                 = new TableHeaderCell();
            oTableCell1.Text            = "कुल योग";
            oTableCell1.ForeColor       = System.Drawing.Color.Red;
            oTableCell1.HorizontalAlign = HorizontalAlign.Right;
            oGridViewRow1.Cells.Add(oTableCell1);
            oTableCell1                 = new TableHeaderCell();
            oTableCell1.Text            = kulyog.ToString("0.00");
            oTableCell1.ForeColor       = System.Drawing.Color.Red;
            oTableCell1.HorizontalAlign = HorizontalAlign.Right;
            oGridViewRow1.Cells.Add(oTableCell1);
            int x1 = (GridView2.Rows.Count + z);
            GridView2.Controls[0].Controls.AddAt(x1, oGridViewRow1);
        }
    }