Grid Lines Are Not Displaying in Grid View

Why am I not seeing grid lines on my gridview

All of the comments on this post are correct to some extent which is, you mention that the issue must rely in the styles, after going line by line in my style sheets I found the culprit style and was able to get the grid-lines to show.

grid lines are not displaying in grid view

You should use as following

<style type="text/css">
#MainContent_GridView1 {
border: solid 1px Black !important;
}
#MainContent_GridView1 tr {
border: solid 1px Black !important;
}
#MainContent_GridView1 td {
border: solid 1px Black !important;
}
</style>

You need to create class for your tr and td you should also look if you have th is render on your browser if so you need to create class as follow

     #MainContent_GridView1 th {
border: solid 1px Black !important;
}

GridView Lines Not Showing up in IE

With the GridView, the declarative bordercolor attribute adds an inline style declaration which only applies to the table itself, not individual cells.

Adding the bordercolor attribute programmatically does not use an inline style, but uses the HTML bordercolor property, which browsers apply to ALL borders inside the table.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (TableCell tc in e.Row.Cells)
{
tc.Attributes["style"] = "border-color: #c3cecc";
};
}

Internal gridlines in GridView in ASP.NET

protected void Page_Load(object sender, EventArgs e)
{
this.myGrid.Attributes.Add("bordercolor", "#000");
}

With the GridView, the declarative bordercolor attribute adds an inline style declaration which only applies to the table itself, not individual cells.

Adding the bordercolor attribute programmatically does not use an inline style, but uses the HTML bordercolor property, which browsers apply to ALL borders inside the table.

See comments under this blog post:

http://codersbarn.com/post/2009/05/31/Set-Color-of-GridLines-in-Gridview.aspx

Data Grid View not showing data from related models?

TL;DR

Quick fix it with the following. In your DealerAddres, add

    public string BaseUrl
{
get => Dealer.BaseUrl;

set => Dealer.BaseUrl = value;
}

Explaining

You have two class DealerAddress and Dealer. You set a list of DealerAddress to the DataSource.

So when the DataGridView starts to render, it will search the properties in the first class.

When you do nameof(DealerAddress.Dealer.BaseUrl) you are actually telling, to the DataGridView, that the class DealerAddress contains that property --- which it does not.


See this for more information.



Related Topics



Leave a reply



Submit