Thursday, March 8, 2007 3:39 PM Christopher

SubSonic Scaffold control - a GridView with Class

So I've been able to dig my teeth into some asp.net hacking recently, and I've been wrestling with learning to use SubSonic in the process.

In dealing with the scaffold control I ran into a funny issue: none of the exposed properties on the scaffold control will output any style info of the GridView that the control uses (that I could figure out anyways). I ended up with black text on a black background. :/ Seeing as I have the source, I decided to give the scaffold control's GridView a little class...hello GridViewCssClass property! I set it up just like the EditTable*CssClass properties, just a string property, with similar attributes to the other properties hanging around there:

[Bindable(true)]
[Category("Display")]
[Description("Sets the CSS class used by the gridview.")]
[DefaultValue(ScaffoldCSS.WRAPPER)] //CDF: just to have something to start with.
public string GridViewCssClass {
	get { return _gridViewCssClass; }
	set { _gridViewCssClass = value; }
}

Then, in the CreateGrid method make it actually do something:

        private void CreateGrid()
        {
            Label lblTitle = new Label();
            surroundingPanel.Controls.Add(lblTitle);
            lblTitle.Text = "<h2>" + schema.Name + " Admin</h2>";

            grid.ID = "grid";
	    grid.CssClass = this.GridViewCssClass;

            surroundingPanel.Controls.Add(grid);

            if (!Page.IsPostBack)
            {
                BindGrid(String.Empty);
            }
            //add a column to the grid for editing
        }

And now I can declaratively set the CssClass that the GridView uses to, oh, say, .whitetext :)

Filed under: ,

Comments

# re: SubSonic Scaffold control - a GridView with Class

Friday, May 18, 2007 2:51 AM by Rob Conery

The gridview is skinnable and you can dress it up by defining the default Gridview skin :)...

Check out the SubSonicCentral (in the new download) and you'll see how we skinned it up ..

# re: SubSonic Scaffold control - a GridView with Class

Friday, June 12, 2009 9:47 AM by mafioso710

Hi, would you like to explain me how is the easy and simple way to change the HeaderText of the GridView control using the SubSonic Scaffolding ? Also, I would like to rename the text of every label control in the Add and Edit Form that is generated with the SubSonic Scaffold.

I got my Scaffolding Form in English idiom but I want to translate into Spanish idiom.

I use SubSonic version 2.1 (Final)

Thanks.