Forum Moderators: open

Message Too Old, No Replies

how do I kill the attributes in a datagrid table?

cellspacing="0" rules="all" border="1"

         

httpwebwitch

6:45 pm on Jan 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My asp:datagrid puts
cellspacing="0" rules="all" border="1" 

in every table. I want to kill those and put in my own values.

putting border="0" into the <asp:datagrid> just adds it to the table tag, like this:

<table cellspacing="0" rules="all" border="0" border="1" ... >

... and that's no good. those are duplicate attributes. With the code above, IE shows no borders. All the other browsers DO show the borders.

There has GOT to be a way I can change border="1" to border="0", and get rid of the "rules" attribute altogether. There just HAS to be.

help!

aspdaddy

7:14 pm on Jan 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



have you tried
BorderStyle="None"?

httpwebwitch

7:38 pm on Jan 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



yes, I've tried that.
BorderStyle="none"

does this:


<table cellspacing="0" rules="all" border="1" id="Results" style="border-style:None;width:550px;border-collapse:collapse;">

and indeed that looks OK in IE. Hooray for styles.

Then I look at the same page in Opera and FireFox, and (!) the table tag does not have the style applied!

Why is it sending different output to different browsers? That's CLOAKING, that is.

in Op and FF, the table tag is rendered like this:


<table cellspacing="0" rules="all" border="1" id="Results" width="550">

Now that I see browsers are not cooperating, this is getting confusing. I thought ASP.NET was a server language, not some sneaky beast that sniffs up my browser and does whatever it pleases! This is not good.

I still have the "rules" attribute (which I want to kill) and border still = 1

TheNige

7:56 pm on Jan 27, 2005 (gmt 0)

10+ Year Member



Have you tried using the CssClass property. Create a class in your style sheet and then set the property to that.

Also, check the GridLines property. If you are using Visual Studio you can see all these properties easily...if not do a search in the help files...best place to look first.

The ASP.Net properties for the controls often do not correspond to the HTML ones...for a reason. So you border property is actually borderwidth.

sharbel

2:59 am on Jan 28, 2005 (gmt 0)

10+ Year Member



Half the reason why 90% of my projects use Repeaters instead of DataGrids. DataGrids are bulky and you dont have as great of control over the presentation/CSS as you do with a Repeater.

I guess, though, its the price you pay for near drag/drop/display capabilities of the datagrid. I just find them way too inefficient compared to the Repeater or even the DataList. Yeah the built in 'stuff' is nice, but there certainly is an opportunity cost for those features.

MrBid

6:54 pm on Feb 8, 2005 (gmt 0)



This gets pretty close. In the PreRender event of your datagrid.
private void dg_PreRender(object sender, System.EventArgs e)
{
DataGrid dg = (DataGrid)sender;
dg.ControlStyle.Reset();
dg.CssClass= "WAW";
return;
}