DataGrid Apply Style file definition dynamic style

Source: Internet
Author: User
Tags define definition
datagrid| dynamic DataGrid apply a style file to define a dynamic style

HBZXF (ah Good)
Http://www.cnblogs.com/hbzxf

In the ASP.net development process, the DataGrid used a very high frequency, for the style of the DataGrid is commonly used by custom different colors to apply to the header of the DataGrid, Footer, EditItem, SelectItem , Item, page, however, if the above style should be set on each page, the efficiency can be imagined, not a few pages a day, And one of the biggest bugs in vs.net is that when we rearrange the page layout for a well-defined DataGrid, we find that all of its events are somehow lost. Maybe sometimes we just have to use the Vs.net format template that we've already provided, but sometimes we have to, and do not let us use the form template how to do (such as customer requirements), I will explain the application of the style file in the DataGrid to define the dynamic style, so that when the customer is not satisfied with a set of color package, It can take a few minutes to redefine a set of things that are more efficient. Cut the crap and see how the following css.css files are defined.

Css.css File Contents:

. dg_header
{
Font-weight:bold;
Color: #FFFFCC;
Background-color: #990000;
border-width:2px;
Border-color: #CC9966;
Border-style:solid;

}
. dg_alter
{
Background-color: #FFE0C0;
Border-left-color:green;
border-width:2px;
Border-color: #CC9966;
Border-style:solid;
}
. Dg_item
{
Color: #330099;
Background-color:white;
border-width:2px;
Border-color: #CC9966;
Border-style:solid;
}
. dg_page
{
border-width:2px;
Border-color: #CC9966;
Border-style:solid;
}

The next task is to apply this style file to the DataGrid in the page.

First insert the following statement between Page <HEAD></HEAD>

<link href= "Css.css" type= "Text/css" rel= "stylesheet" >

Then select the DataGrid on the page and change the cssclass that you want to apply the style attribute value to

For example:
Click the HeaderStyle property to the left of the cross to open the option to apply the CssClass style Dg_header

Finally bind the DataGrid to see if the style has been applied, and if there are no applications there are two possible

1, remove the system automatically apply the style

2, see if the Css.css file is defined correctly





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.