problm wid grid view

Posted by Rickeybglr under ASP.NET on 11/30/2012 | Points: 10 | Views : 739 | Status : [Member] | Replies : 1
i have a 2 columns in grid view. 1st col value mapped with 2nd col. wht i need to do is:if thr r multiples rows, (eg 5) thn in ths case 1st col 1st row value="abc" and oter row value of 1st col. shud be blank.
to undrstnd ths consider eg: one person have multiple mobile no.
so
Name_person 123
blank 456
blank 478
blank 458
like ths.
plz suggest




Responses

Posted by: Manoj_B on: 12/4/2012 [Member] Starter | Points: 25

Up
0
Down
hii,

write the code in prerender envent of gridview1

protected void Gridview1_PreRender(object sender, EventArgs e)

{
for (int i = Gridview1.Rows.Count - 2; i >= 0; i += -1)
{
if (Gridview1.Rows[i].Cells[0].Text == Gridview1.Rows[i + 1].Cells[0].Text)
{
Gridview1.Rows[i].Cells[0].RowSpan = Gridview1.Rows[i + 1].Cells[0].RowSpan < 2 ? 2 : Gridview1.Rows[i + 1].Cells[0].RowSpan + 1;
Gridview1.Rows[i + 1].Cells[0].Visible = false;

}
}
}


Then your o/p wil be-

Name_person 123
456
blank 478
458




Thanks & Regards
Manoj Kumar

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response