ASP.NET DataGrid and styling with CSS
I have never had an issue with putting
th
{
background: #900;
}
as a style in a css file and have that apply to the header row of an ASP datagrid. But for some reason today, I have a grid that is getting output with everything in TBODY and even the headers are in TD tags. Any ideas?
开发者_开发问答One thing that is a little different for me is this is bound to a List instead of to a DataTable. Is this a normal behavior? Easy way to fix?
UPDATE
<asp:DataGrid ID="dgEmployees" runat="server">
</asp:DataGrid>
THE VALUE OF AN IDE Okay, so my DataGrid should have been a GridView. Teaches me to go and type in the tag by hand again. Could not figure out what and the heck I had done wrong until I went and looked at an another project of mine.
CSS doesn't care how you fill your datagrid. It could come from a datatable, a reader, a custom Object (employee, product, , etc). So it is not an issue because you are using a list instead of a datatable.
You will need to post your CSS with your datagrid code.
Here is an excellent link on how to use CSS with a datagrid / gridview:
http://atashbahar.com/post/GridView-makeover-using-CSS.aspx
Here is one specifically for datagrids:
http://www.codeproject.com/KB/webforms/cssgrid.aspx
I personally do not use datagrids, should be using grid view or some sort of repeater.
精彩评论