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.