in my grid data is represented as Datewise . So I want To Group the data that has same Date. and After Grouping Insert space for different Date.
I tried to Achive this by this code But Was faild;
Even Now i Have a Checkbox in footer that perform Java script Opration for aprove or disaproove candidate. by inserting space . aprooval and disaprooval stops working ..
DataRow lastRow = null;
string b = "";
protected void GridClaimView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
TableHeaderCell cell = new TableHeaderCell();
cell.Text = "Balance <br /> Amount";
e.Row.Cells.AddAt(14, cell);
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
double Amount1 = 0;
double.TryParse(e.Row.Cells[11].Text, out Amount1);
AdvanceAmount += Amount1;
double Amount2 = 0;
double.TryParse(e.Row.Cells[12].Text, out Amount2);
ClaimAmount += Amount2;
double Amount3 = 0;
double.TryParse(e.Row.Cells[13].Text, out Amount3);
Kilometer += Amount3;
TableCell cell = new TableCell();
cell.Text = (Amount2 - (Amount1 + Amount3)).ToString();
e.Row.Cells.AddAt(14, cell);
CheckBox chkBxSelect = (CheckBox)e.Row.Cells[0].FindControl("cbxSelect");
CheckBox chkBxHeader = (CheckBox)this.GridClaimView.HeaderRow.FindControl("cbxSelectAll");
chkBxSelect.Attributes["onclick"] = string.Format
(
"javascript:ChildClick(this,'{0}');",
chkBxHeader.ClientID
);
//if (e.Row.Cells[16].Text == "DisApproved")
//{
// e.Row.Enabled = false;
//}
//else
//{
// e.Row.Enabled = true;
//}
}
string a = "";
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRow thisRow = ((DataRowView)e.Row.DataItem).Row;
DateTime thisDate = thisRow.Field<DateTime>("TimeSheetDated");
a = thisDate.ToString("d");
if (b != null)
{
// DateTime lastDate = lastRow.Field<DateTime>("TimeSheetDated");
//b = lastDate.ToString("d");
if (a != b)
{
TableCell tc = new TableCell();
tc.Text = " ";
tc.Height = Unit.Pixel(20);
GridView gv1 = (GridView)sender;
tc.ColumnSpan = gv1.Columns.Count;
GridViewRow gr = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
gr.Cells.Add(tc);
Table gvTable = (Table)e.Row.Parent;
gvTable.Controls.Add(gr);
}
}
b = a;
lastRow=thisRow;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[11].Text = AdvanceAmount.ToString();
e.Row.Cells[12].Text = ClaimAmount.ToString();
e.Row.Cells[13].Text = Kilometer.ToString();
TableCell cell = new TableCell();
cell.Text = (ClaimAmount - (AdvanceAmount + Kilometer)).ToString();
e.Row.Cells.AddAt(14, cell);
}
}