Applying styles to GridView control in external CSS

Alright, I've looked everywhere but I still can't seem to find a simple explanation of how to apply styles to a GridView control. 

I just need to know the attributes of a GridView control that can be customized.

For example, I already figured out that I can customize the "caption" attribute: my GridView control has 'CssClass = "thisClass"' and my stylesheet has '.thisClass caption { color:Blue: }'

I need to get the names of the attributes of the GridView control such that I can eliminate the border and apply other formatting styles. Thanks a bunch in advance.
8/24/2006 4:26:58 PM 72751 articles. 1 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 50

Can anybody offer some insight? Thanks.
8/24/2006 7:53:01 PM
Haven't played with this too much just yet.

But I think if you bring up your page in design view and select your GridView, then review your Properties using the F4 key, you will see various styling elements. You should see the BorderStyle property and you can set it to none. Then if you scroll further down you'll see a bunch of styles under a Styles grouping that you can expand and set properties on.

Once you do this, you can see your settings in the HTML view. Here's where it gets a little tricky.

You'll see something like this:
        <asp:GridView ID="GridView1" runat="server" Font-Names="Arial" Font-Size="Small" BackColor="LimeGreen" AutoGenerateColumns="False" DataKeyNames="CustomerID" DataSourceID="SqlDataSource1" BorderStyle="None" BorderColor="Blue">
                <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" />
                <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />
                <asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" />
                <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" SortExpression="ContactTitle" />

Copy that block of code. And do a Ctrl-N to create a new Skin file. You'll see some notes to help you along creating a skin. I think it should look something like the above code but you delete some stuff. It'll end up looking something like this:

<asp:GridView runat="server"

Paste it into the skin file.

Note: you can put other entries for other types of server controls in this file too. And any controls on a page that uses this skin would following the attribute settings according to the skin.

You save your skin. And then you go back to the properties sheet for the Document and set the Theme to the skin that you just created.

You'll see the StyleSheetTheme and Theme on the Document Properties. They're very similar. Here's a good read on the precedence:

Now, technically, the "pretty settings" that you set at the GridView level for GridView1 is no longer necessary, you could go to the HTML view and delete any attributes that you have set for GridView1. The setttings from the Skin file/Theme would take effect.

Usually, you beautify server controls using Skins and any regular HTML or Div attributes should be set via the CSS file.

You can drop the CSS file inside your app_themes/skin folder. So that CSS file will take effect whenever a page has the StyleSheetTheme/Theme set to a Skin. You wouldn't need to set the StyleSheet property, at least I don't think. I tested it once before, but I might remember wrong.

I think this should clarify everything for you. Let me know how it goes.

8/25/2006 6:10:39 AM

Similar Artilces:

Apply CSS Style from External file on Composite Controls
hi  ,  i am creating a Menu composite control , i want to add the CSS Style from (style.css) external file in this menu control content. What's the way i used for this ?  Shah Add this code to your code of the control        HtmlLink link = new HtmlLink();        link.Href = "~/style.css";        link.Attributes.Add("rel","stylesheet");        link.Attributes.Add("type", "text/css");  ...

Trouble controlling .net controlls with CSS
 I am trying to control the :hover css property on <asp: Button> controls. Basically the css is working correctly to set the initial look of the button, but nothing is happening when I hover over the button. Here is my code:CSS:.sidebarButton{    width: 168px;     height: 45px;     background-color: #666666;     text-align: left;    font-weight: bold;    font-family: Century Gothic;    font-size: 13pt;    color: White;    border-style: none;  ...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,,MC...

Gridview control embedded in another gridview control
I am writing an ambulance crew scheduling application on the web and I need some help completing the last part.  I have an access database that has three tables: user table, shift table (describing the shifts available), and a schedule table (that stores shift by shift_id and user by user_id).  I have a gridview control that will display the available shifts but I cannot get the embedded gridview control that will display the user that is signed up for each shift to display because I cannot figure out how to use the OnRowDataBound method.  I need a simple VB example of how to...

Applying CSS styles to the Treeview Control
I am ttying to apply a background image and a hover image to the nodes in my treeview control I have specified my styles in a css class and have applied this class to the CssClass attribute of the NodeStyle of my treeview but when I load the treeview I do not see the images can anyone tell me what I may be doing wrong or if this is at all possible to do with this control.--------------------------------------------------Sincerely,Michael ReyerosPlease remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your ...

Help Req: !!! :- On Disabling Controls Present inside a Gridview control
Hi All, We have A requirement Where we have disable controls inside a grid.These controls can be textbox, DropDownlist (in TemplateField), ComandField present inside the grid.We have to call a generic method for doing the same .(since it can be done for multiple grid.) PFB the code snippet we use. Which disables all the controls inside the page.The bolded part of the code is used to loop inside a grid view.(Not Working.)Is this ideal way to deal with the requirement.Or can someone suggest be a better way.        public void DisableMe(Page p1, st...

Applying CSS style to HTML table control
Hi freinds,  Can i apply css styles to html table control in web form.If yes den please tell me how??? If possible den please send me code. ThanksI have tried my level best to help u but i cant assure that it will help u.Fozia You can use the property CssClass of the table to refer to a class name in your css markup: <asp:Table id="Table1" runat="server" CssClass="mytable"> .... </asp:Table> Then, in your css you can do: .mytable { background-color: grey; } ..mytable td { padding: 4px; } Here's an article on how to style t...

There is a Gridview Control in the tmplate field of another GridView Control.
    For instance,a gridview displays the information of the  students in a class.A table is recording the information except their mark.There is another table recording the mark of the students whose foreign key is the primary key of the previous table.   string strSQLconnection=".................."; SqlConnection sqlCononection=new SqlConnection(strSQLconnection); SqlCommand sqlCommand=new SqlCommand("select * from stuendent where classID=1",sqlConnection); SqlConnection.Open(); SqlDataReader reader=sqlCommand.ExecuteReader(); GridVie...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

SqlDataSource Control and Gridview control
Hi, I'm new to web development and learning about these controls.  The books teach you to bind the gridview control to an sqldatasource to perform delete,update,insert functions as well as to list the records in a table.  Is this standard practice for real world applications?  Or is there another way that should be used to display/manage table data in the gridview control? Thanks. Tulsi Using a sqldatasource is the best way I know of for binding data to a gridview.  (I'm pretty new to web development too, so maybe someone else can chime in if they know someth...

validation controls in gridview control
hi, I m using the grid view to add,edit,update,delete the data table. Everything is fine.In the footertemplate i get the values through text boxes and drop down lists.i took place sm validation controls to validate these controls.the problem arises here.if i want to update the record after i click the edit button, it validate the page n dont allow me to update the record.I want to validate the particular controls only. i checked if any causes validation property for update button.there is nothing like that. pls help me.. thanks in advance gowri  regards,gowripillaimark as answer if...

Precise Control over GridView controls?
Hi.When you create a GridView in visual studios and bind it to, say, an SqlDataSource, it automatically creates fields and templates according to the types retrieved from the data source. (ie, it creates a Label for number/string columns, checkboxField for booleans, etc). My question: How do I control precisely what WebControls/Fields are used for each column?thanks,Tombow Hi Tombow Using TemplateFields you can control that explicitly.  See the Data Tutorial #12 at for more details. Hope that helps. AaronDon't...

using controlS to control a gridview
This question is probably posted but i did not bother to look at 10,000+ posts so i am sorry. I've seen the tutorial where he builds a dataset and uses a gridview and controls the gridview with the drop down list box. What i am trying to do is to control the gridview with 2 drop down list boxes. First select the Country you life in and then the State. I've looked at the grid view properties but couldn't find where i can add another parameter. Is it possible to control a grid view (or any form of displaying the information) with more than 1 controller? Thank You.  ...

Web resources about - Applying styles to GridView control in external CSS -

Applying To Schools? Mind Your Facebook Profile
... and 12 percent of college admissions officers. Bottom line: Mind your Facebook profile and other social media accounts if you’re applying to ...

Workers applying binder to brick paving on Lafayette Ave. - Flickr - Photo Sharing!
B&W photograph of WPA workers applying binder to vitrified brick paving on Lafayette Ave. in Baltimore, MD, ca. 1935 (WPA Project# 323) Creator/Author: ...

High School Student, Teacher Applying For Same Summer Waitressing Job - YouTube
Subscribe to The Onion on YouTube: Noting that it would be nice to finally have a little spending cash on hand, both Pittsfield ...

Overseas workers will be allowed to work for a year without applying for 457 visas
A new temporary entry permit proposed by the Department of Immigration to allow overseas workers to stay in Australia for a year without a 457 ...

India's jobs shortage: PhDs, graduates among millions applying for menial jobs
Record number of applications for menial posts a sign Prime Minister Narendra Modi isn't creating his promised 100 million jobs fast enough. ...

Applying uniform laws and putting nature first
The question must be asked: Do any of our governments care about nature?

Applying Truth and Reconciliation to US police violence
A mistrial was declared this week in the Freddie Gray trial. We talk to civil rights lawyer Fania Davis about applying a truth and reconciliation ...

Applying innovation to journalism curricula
Journalism educators went back to school for three days recently at The Poynter Institute's Teachapalooza 2012 looking for inspiration about ...

Report: Google slowing down hiring, applying stricter rules to company spending
The Wall Street Journal reports that Google tightening the reigns when it comes to hiring and spending as a company. The report, citing venture ...

Canalys: Xiaomi and Huawei push Apple down into 3rd place in China, but still applying pressure
... may have fallen to around 12.2% … However, Canalys said that Apple continues to expand its sales activities and that it and Huawei are applying ...

Resources last updated: 12/29/2015 8:59:43 PM