So my existing structure is
<table>
<tr>
<th>header</th>
</tr>
<tr>
<td>cotent</td>
</tr>
</table>
The DataGrid is adding a bunch of stuff I do not desire to be there, is it possible to remove this extra information so I don’t have to make heavy modifications to my CSS file?
Here is how the above table looks after DataGrid.
<table id="ContentPlaceHolder1_articleList" headertext="File Name" rules="all">
<tr>
<td>Header</td> <!-- I need this to be a TH?? -->
</tr>
<tr>
<td>Content</td>
</tr>
</table>
The biggest issue here is I need the header row to be <th> and not <td>. And I need the table to just be the ID and runat="server" are not big deals, not sure what the rules="all" does.
Here is my asp.net code.
Code Behind Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("examfilemanager"));
articleList.DataSource = dirInfo.GetFiles();
articleList.DataBind();
}
aspx page:
<asp:DataGrid Enabled="false" runat="server" ID="articleList" AutoGenerateColumns="false" AlternatingItemStyle-BackColor="#EEEEEE" HeaderText="File Name">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name" />
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
<asp:BoundColumn DataField="Length" HeaderText="Filer Server" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,### bytes}" />
</Columns>
</asp:DataGrid>
Try setting
UseAccessibleHeaderto true:If possible you really should use the
GridViewcontrol instead and take advantage of the many features that aren’t available to theDataGridcontrol. The traditionalDataGridcontrol is more of an antiquated relic at this point.