views:

114

answers:

2

For those of us who are aesthetically challenged, is there a way to apply JQuery's themes (e.g. redmond) to an ASP.NET gridview?

Something like ...

$(document).ready(function() { $(function() { $("<%= MyGridView.ClientID %>").Table(); }); });

Perhaps there's an addin that would emulate that type of functionality?

A: 

Just give your gridview a css class and use that in the jquery selector. That way you can have a standard javascript file in all your pages and all you have to do is add the relevent css class to a gridview and it will be styled.

Ben Robinson
I had tried that but did see any difference. Is there a table-oriented class in any of the themes?
James Evans
http://www.smashingmagazine.com/2008/08/13/top-10-css-table-designs/ Here are a couple table css examples that will work with the gridview
Jordan Johnson
A: 

The gridview html renders to a table. If you add css class to it then you will be fine. Also, add the following in the gridview Databound event so the header does not render as a row.

protected void gridView_DataBound(object sender, EventArgs e)
    {
        if (gridView.Rows.Count > 0)
        {

            gridView.UseAccessibleHeader = true;

            gridView.HeaderRow.TableSection = TableRowSection.TableHeader;
            gridView.HeaderRow.CssClass = ///--Optional--
            gridView.FooterRow.TableSection = TableRowSection.TableFooter;
            gridView.PagerSettings.Visible = true; ///Helps footer
        }
    }
Jordan Johnson