views:

578

answers:

4

I'm working on a web-enabled version of our existing winforms project. Gridviews seem to be an ample replacement for the datagrids that we've been using. We have extensive table styles written for the old datagrids. Is it possible to reuse this code to apply a style to a gridview?

If a re-write is necessary, what is the best way to style the gridviews?

+1  A: 

Using themes and skin files is what you need.

Check this link : http://msdn.microsoft.com/en-us/library/ykzx33wh(VS.80).aspx

Canavar
+1  A: 

I don't think there is an easy way to port styled from datagrids to gridviews.

You might consider using the CSS Friendly Control Adaptors as a mechanism for applying the styles:

Kramii
+1  A: 

You can copy style from datagrids to gridviews via the CopyFrom() method.

To copy a header style from a datagrid to a grid view:

GridView1.HeaderStyle.CopyFrom(DataGrid1.HeaderStyle);

Footer Style:

GridView1.FooterStyle.CopyFrom(DataGrid1.FooterStyle);

Hope this helps.

Phaedrus
+1  A: 

The GridView control has several properties of type TableItemStyle (FooterStyle, HeaderStyle, RowStyle, etc).

These TableItemStyle properties contain a method called CopyFrom that expects a System.Web.UI.WebControls.Style. You won't be able to copy styles for your WinForms DataGrid using this method.

Your quickest path is probably to rewrite and use the FooterStyle, HeaderStyle, RowStyle, etc properties of the GridView.

Shawn Miller