Click here to Skip to main content
15,885,365 members

Comments by AR547 (Top 44 by date)

AR547 6-Jun-14 4:02am View    
Almost done..but cannot generate new rows on next click. it is merging cells on each row now.
here is my code in RowDataBound:

protected void GV_Requests_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState != DataControlRowState.Edit) // check for RowState
{
if (e.Row.RowType == DataControlRowType.DataRow) //check for RowType
{
//Loop through all the cells in the row
for (int j = 0; j < GV_Requests_Sys.Rows.Count+1; j++)
{
if (j % 2 !=0)
{
e.Row.Cells[0].Text = "Request<br/>Description";
e.Row.Cells[0].ColumnSpan = 2;
e.Row.Cells[1].ColumnSpan = 4;
for (int i =1; i < e.Row.Cells.Count - 1; i++)
{
Checking If current cell is same as next cell value
if (e.Row.Cells[i].Text == e.Row.Cells[i + 1].Text)
{
e.Row.Cells[i + 1].Visible = false;
}
}
}
}
}
}
}
AR547 6-Jun-14 4:02am View    
Almost done..but cannot generate new rows on next click. it is merging cells on each row now.
here is my code in RowDataBound:

protected void GV_Requests_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowState != DataControlRowState.Edit) // check for RowState
{
if (e.Row.RowType == DataControlRowType.DataRow) //check for RowType
{
//Loop through all the cells in the row
for (int j = 0; j < GV_Requests_Sys.Rows.Count+1; j++)
{
if (j % 2 !=0)
{
e.Row.Cells[0].Text = "Request<br/>Description";
e.Row.Cells[0].ColumnSpan = 2;
e.Row.Cells[1].ColumnSpan = 4;
for (int i =1; i < e.Row.Cells.Count - 1; i++)
{
Checking If current cell is same as next cell value
if (e.Row.Cells[i].Text == e.Row.Cells[i + 1].Text)
{
e.Row.Cells[i + 1].Visible = false;
}
}
}
}
}
}
}
AR547 6-Jun-14 2:34am View    
And how will I create a new row after data has been bound. Like Headers(1st row) and 2nd row created and now I need to create new row of Remarks and then I will check those cells with null values and will use your code here.
AR547 6-Jun-14 2:23am View    
Dear Friend,
This code will work if we have to compare the same values of cells. But data is coming from DataTable. The 3rd Row's first column's text is hard coded as Remarks and the 2nd column will have Random Text binded from textbox outside the gridview. The other 3rd 4th and 5th column should be merged.
AR547 6-Jun-14 2:19am View    
Rohan,
Got your point. But I am not comparing any cell having same values, actually I need to create a 3 row with 2 columns in which I have to bind data from a textbox outside the gridview. But I tried that trick of applying 1 in rowIndex in RowDataBound but it was creating extra duplicate rows of that 3rd row.
:(