Datagrid and formatting problems

T

tshad

I have been trying to figure out what the Datagrid is doing to create its
formatting.

I found that some of my Datagrids have a 3D type of border and sometime it
has a straight line. I finally found that it comes down to whether there is
a "rules=all" attribute (which gives me just a thin black line). If that
attribute is not there, you get a 3D effect.

I haven't yet been able to figure out what causes it. Here is the table def
that has the rules in it:

<table cellspacing="0" cellpadding="3" rules="all" border="1" id="DataGrid1"
style="margin: 5px 5px 5px 5px; padding: 5px;">

The DataGrid is defined as:

<asp:DataGrid AllowPaging="false"
AllowSorting="True"
AutoGenerateColumns="false"
CellPadding="3"
CellSpacing="0"
ID="DataGrid1"
runat="server"
ShowFooter="false"
ShowHeader="true"
OnSortCommand="SortDataGrid"
borderstyle="none"
style="margin: 5px 5px 5px 5px; padding: 5px;"
I have borderStyle as "none" here and I still have a border - why is that?
And what causes the "rules" attribute?

Thanks,

Tom
 
T

tshad

tshad said:
I have been trying to figure out what the Datagrid is doing to create its
formatting.

I found that some of my Datagrids have a 3D type of border and sometime it
has a straight line. I finally found that it comes down to whether there
is a "rules=all" attribute (which gives me just a thin black line). If
that attribute is not there, you get a 3D effect.

I haven't yet been able to figure out what causes it. Here is the table
def that has the rules in it:

<table cellspacing="0" cellpadding="3" rules="all" border="1"
id="DataGrid1" style="margin: 5px 5px 5px 5px; padding: 5px;">

The DataGrid is defined as:

<asp:DataGrid AllowPaging="false"
AllowSorting="True"
AutoGenerateColumns="false"
CellPadding="3"
CellSpacing="0"
ID="DataGrid1"
runat="server"
ShowFooter="false"
ShowHeader="true"
OnSortCommand="SortDataGrid"
borderstyle="none"
style="margin: 5px 5px 5px 5px; padding: 5px;"

I have borderStyle as "none" here and I still have a border - why is that?
And what causes the "rules" attribute?

I stripped down my code and have - no styles - no css and just the DataGrid
with the code to fill it.

Here is the Datagrid:

<asp:DataGrid
ID="DataGrid1"
runat="server"
ShowFooter="false"
BorderStyle="none"<Columns>
<asp:BoundColumn DataField="Applied"
ReadOnly="true"
Visible="True">
<itemstyle ForeColor="red" />
</asp:BoundColumn>
<asp:HyperLinkColumn DataTextField="JobTitle"
DataTextFormatString="{0}" DataNavigateUrlField="PositionID"
DataNavigateUrlFormatString="displayPosition.aspx?PositionID={0}"
HeaderText="Job Title"
SortExpression="JobTitle"/>
<asp:BoundColumn DataField="Client"
HeaderText="Company"
ReadOnly="true"
Visible="True"
SortExpression="Client"/>
<asp:BoundColumn DataField="Location"
HeaderText="Location"
ReadOnly="true"
Visible="True"
SortExpression="Location"/>
<asp:BoundColumn DataField="Posted"
HeaderText="Date Posted"
ReadOnly="true"
Visible="True"
SortExpression="DatePosted">
<Itemstyle CssClass="datedisplay" />
</asp:Boundcolumn>
<asp:BoundColumn DataField="lastUpdated"
HeaderText="Last Updated"
ReadOnly="true"
Visible="True"
SortExpression="DateUpdated">
<Itemstyle CssClass="datedisplay" />
</asp:Boundcolumn>
</Columns>
</asp:DataGrid>

Here is the Table tag:

<table cellspacing="0" rules="all" border="1" id="DataGrid1">

The BorderStyle doesn't have any effect at all. Why is there a border?
Where is this rules coming from?

If I add border=0,

I get the tag:

<table cellspacing="0" rules="all" border="0" border="1"
id="DataGrid1">

What gives?

This is driving me crazy. I am getting all kinds of inconsistent results on
my pages. Some DataGrids have the rules=all and some don't. The
BorderStyle, doesn't seem to work anywhere. None or Solid, doesn't seem to
do anything, but border=0 or border=1 seem to work (if rules=all is not
there).

Thanks,

Tom
 
E

Elton Wang

Hi,

If you want 3D type of border, set borderStyle to Outset
or Ridge. If you don't want border line, set BorderWidth
as 0px.

Hope it helps,

Elton Wang
(e-mail address removed)
 
T

tshad

Elton Wang said:
Hi,

If you want 3D type of border, set borderStyle to Outset
or Ridge. If you don't want border line, set BorderWidth
as 0px.

I would have thought so also. The problem is that borderStyle doesn't seem
to be working. And the rules="all" is what is making the line solid (not
3D).

Tom
 
T

tshad

Here is apparently what is happening and is what just drives me crazy about
these objects.

If you have:
<asp:DataGrid
border=3
id="DataGrid1"
runat="server"
Gridlines="None">

Gridlines = "none" - gives you no "rules" attribute and border=x - gives you
an x-size borders and gridlines.. This will give you a 3D effect. If you
have no border attribute or border=0 - you will get no borders and no
gridlines. The above tag will give you the following:

<table cellspacing="0" border="3" border="0" id="DataGrid1">

You will notice the 2 border attributes. If you have border=0 or no border
attribute, you will get border=0 in the table tag. Not sure why I get 2
border attributes if I put in a border tag with a value > 0.

If you have the following tag:

<asp:DataGrid
border=0
id="DataGrid1"
runat="server"
With the Gridlines attribute taken out, you will get the rules="all"
attribute.

<table cellspacing="0" rules="all" border="0" border="1"
id="DataGrid1">

You will also note that there is 2 borders here, one with 0 and one with 1.
This will give you thin gridlines with no border around the table. If you
change the border to something line 2, you will get:

<table cellspacing="0" rules="all" border="2" border="1" id="DataGrid1">

This will give you the same thin gridlines, but the outside border will be a
thick line based on the border attribute (the larger the number the thicker
the line, but the gridlines will still be thin.

So if you want to have thin gridlines, whether you have a border or not,
leave out the gridlines tag (this is probably some default). If you want 3D
lines or no Gridlines, put the gridlines="none" in.

If you have:
<asp:DataGrid
border=2
id="DataGrid1"
runat="server"
BorderStyle="Dotted"
BorderWidth="2"
gridlines="None"
This doesn't seem to effect the DataGrid whether you have the gridlines tag
or not (the BorderStyle and BorderWidth tags - which are supposed to be
available).

Very frustrating.

Tom

snip
 
T

tshad

tshad said:
Here is apparently what is happening and is what just drives me crazy
about these objects.

If you have:
<asp:DataGrid
border=3
id="DataGrid1"
runat="server"
Gridlines="None">

Gridlines = "none" - gives you no "rules" attribute and border=x - gives
you an x-size borders and gridlines.. This will give you a 3D effect. If
you have no border attribute or border=0 - you will get no borders and no
gridlines. The above tag will give you the following:

<table cellspacing="0" border="3" border="0" id="DataGrid1">

You will notice the 2 border attributes. If you have border=0 or no
border attribute, you will get border=0 in the table tag. Not sure why I
get 2 border attributes if I put in a border tag with a value > 0.

If you have the following tag:

<asp:DataGrid
border=0
id="DataGrid1"
runat="server"

With the Gridlines attribute taken out, you will get the rules="all"
attribute.

<table cellspacing="0" rules="all" border="0" border="1"
id="DataGrid1">

You will also note that there is 2 borders here, one with 0 and one with
1. This will give you thin gridlines with no border around the table. If
you change the border to something line 2, you will get:

<table cellspacing="0" rules="all" border="2" border="1" id="DataGrid1">

This will give you the same thin gridlines, but the outside border will be
a thick line based on the border attribute (the larger the number the
thicker the line, but the gridlines will still be thin.

So if you want to have thin gridlines, whether you have a border or not,
leave out the gridlines tag (this is probably some default). If you want
3D lines or no Gridlines, put the gridlines="none" in.

If you have:
<asp:DataGrid
border=2
id="DataGrid1"
runat="server"
BorderStyle="Dotted"
BorderWidth="2"
gridlines="None"

This doesn't seem to effect the DataGrid whether you have the gridlines
tag or not (the BorderStyle and BorderWidth tags - which are supposed to
be available).

An addendum:

If you have gridlines="none" and border=1 or higher, you get a 3D grid which
is the same size no matter what. You can't seem to affect the color using
either BorderColor="#990033" or style="border-color=#990033;". The grid
looks good in Mozilla, but you can hardly see it in IE. If you want to set
the color in IE, you can set gridlines="both" and then
BorderColor="#990033" works in IE, but not in Mozilla. In Mozilla, you will
get the same 3D grid, regardless of the border value (as long as it is > 0).

I am having a hard time getting any consistancy here.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top