views:

20

answers:

1

I got two gridviews in the same page, which basically displays the same type of data (different amount, same structure, same design...). There is a lot of conditions inside the RowDataBound that are all the same (99%), so I wanted to reduce the code. Use it once.

I thought I'd use the same RowDataBound. It works all right.

However, I need to make the one condition (the rest ... 1%) that is something like if(leftgrid) then display a star if(rightgrid) then display no star .... something like that...

How do i do that ?

Thanks

+1  A: 

This should do it:

protected void RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.Parent.Parent.ID == "GridView1")
    {
        //do 1% for GridView1
    }
    else
    {
        //do 1% for GridView2
    }
}
Mike Polen
thanks. it works! this never occurred to my mind :)
Swoosh
No problem...at times my mind gets stuck as well...that is why we have SO!
Mike Polen