Border settings in the gridview

Source: Internet
Author: User
Today, when using the gridview, the following problem occurs: after the borderstyle and bordercolor of the gridview runat = "server" bordercolor = "# b1c3d9" borderstyle = "solid" borderwidth = "1px"> change only the four sides of the gridview. The internal border is invalid. After going online, I finally found a solution:

The bordercolor attribute in the HTML tag specifies the border color of the table, whether it is the four border of the table or the cells inside the table

The border color is set. However, in the Asp.net gridview control, after bordercolor is setCode

Is as follows:

<Table class = "gridview_m" cellspacing = "0" rules = "all" border = "1" id = "ctl00_content_gv_1"

Style = "border-color: #93c2f1; border-collapse: collapse;">

The original bordercolor attribute set in the gridview is the attribute in CSS, and the result is that the color of the four borders in the gridview has changed,
However, the color of the internal cell is gray, not the color you specified.

Many friends on the Internet have discussed this problem. One solution is to use code to add the real bordercolor attribute to the gridview.
For example:

This. gridview1.attributes. Add ("bordercolor", "Red ");

This disadvantage is that it is not flexible. If you need to use a topic to control the interface style
This statement is not suitable in the code.

The mechanism provided by CSS can better solve this problem.

For example
In the topic, set the cssclass of the gridview to gridview_m.

<Asp: gridview runat = "server" cssclass = "gridview_m">
<Headerstyle cssclass = "girdview_head"/>
<Rowstyle cssclass = "gridview_row"/>
<Pagerstyle horizontalalign = "center"/>
</ASP: gridview>

Then set in the CSS style sheet:

Table. gridview_m
{
Border-collapse: collapse;
Border: solid 1px #93c2f1;
Width: 98%;
Font-size: 10pt;
}

Table. gridview_m TD, th
{
Border-collapse: collapse;
Border: solid 1px #93c2f1;
Font-size: 10pt;
}

The preceding CSS styles include other styles, such as table. gridview_m TD and Th.

Apply the style to the th and TD labels in the table of class = "gridview ".

In this way, the border problem of the gridview is solved.

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.