Clone a gridview's template styles

  • Thread starter Thread starter deostroll
  • Start date Start date
D

deostroll

I was trying to email the gridview's content, but while trying to render the
control's html using the textwriter I got an error. The workaround I found to
this was instantiate another (2nd) gridview, and bind that separately. I
don't need to start explicit database connections to fetch the data; I can
use the 1st gridview as my source (iterating thru its rows and populating a
datatable)...Now is there a possibility where I can clone its look and feel
so that when my 2nd gridview renders it renders will the styles I see off my
web page?

--deostroll
 
I was trying to email the gridview's content, but while trying to render the
control's html using the textwriter I got an error. The workaround I found to
this was instantiate another (2nd) gridview, and bind that separately. I
don't need to start explicit database connections to fetch the data; I can
use the 1st gridview as my source (iterating thru its rows and populatinga
datatable)...Now is there a possibility where I can clone its look and feel
so that when my 2nd gridview renders it renders will the styles I see offmy
web page?

--deostroll

I think the easiest way is to use css and apply the same cssclass to
both grids

GridView2.CssClass = GridView1.CssClass

otherwise you would probably need to set each property

GridView2.GridLines = GridView1.GridLines
GridView2.BorderStyle = GridView1.GridLines
GridView2.BorderColor = GridView1.BorderStyle
 
GridView2.CssClass = GridView1.CssClass

We don't assign CssClass to anything initially. Moreover for GridView1 we do
not manually code for looks. We use the Auto Format feature from the
gridview's design-time menu...
 
Back
Top