473,651 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrid and border-collapse:collap se style

Hi

I need a datagrid on a page, but it is rendered with the style
"border-collapse:collap se;". I do not need this style. It interferes with
the settings in my CSS file. I tried to supress it with this code (1 line of
code):

DataGrid1.Contr olStyle.Reset() ;

which works.
Unfortunately I need cellspacing="0"
When I set cellspacing to zero like this (2 lines of code):

DataGrid1.Contr olStyle.Reset() ;
DataGrid1.CellS pacing = 0;

then the datagrid is rendered as a table and the
style="border-collapse:collap se;" comes back again!

How can I get rid of it?
Thanks

Vaclav

Nov 17 '05 #1
1 7610
Hello Vaclav,

I have seen this question in the group. Here is the reply from ASP.NET
Development team:

----------------------------------------------------------
No there isn't a way to get rid of border-collapse if you set CellSpacing
to 0.

Perhaps there should have been a way to override this behavior. Tables
with cellspacing=0 with the borders collapsed don't look like they have
really 0 cellspacing (visually), because each cell has a border. Therefore
to make it appear that there is absolutely no space between cells, we add
this style attribute.

Here's what you should do:
1. Write a MyTable control deriving from Table
2. In there override CreateControlSt yle to plug in a derived style
protected override Style CreateControlSt yle() {
return new MyTableStyle(Vi ewState);
}
3. Write the MyTableStyle class deriving from TableStyle like so:

public class MyTableStyle : TableStyle {
private bool _rendering;

public override int CellSpacing {
get {
if (_rendering) {
return -1;
}
return base.CellSpacin g;
}
set {
base.CellSpacin g = value;
}
}

public override void AddAttributesTo Render(HtmlText Writer writer,
WebControl owner) {
try {

_rendering = true;
base.AddAttribu tesToRender(wri ter, owner);
}
finally {
_rendering = false;
}
int n = CellSpacing;
if (n >= 0) {
writer.AddAttri bute(HtmlTextWr iterAttribute.C ellSpacing,
n.ToString(Cult ureInfo.Invaria ntCulture));
}
}
}

That should do the trick... of course this is email code based on memory of
the code, so it might need small modifications to fully work.

-------------------------------------------------

Hope it helps.

Best regards,
yhhuang
VS.NET, Visual C++
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
!From: "Vaclav Jedlicka" <vj*******@iol. cz>
!Subject: datagrid and border-collapse:collap se style
!Date: Thu, 26 Jun 2003 12:47:12 +0200
!Lines: 28
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <Od************ **@tk2msftngp13 .phx.gbl>
!Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
!NNTP-Posting-Host: 195.47.25.99
!Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
!Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1550 60
!X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
!
!Hi
!
!I need a datagrid on a page, but it is rendered with the style
!"border-collapse:collap se;". I do not need this style. It interferes with
!the settings in my CSS file. I tried to supress it with this code (1 line
of
!code):
!
!DataGrid1.Cont rolStyle.Reset( );
!
!which works.
!Unfortunately I need cellspacing="0"
!When I set cellspacing to zero like this (2 lines of code):
!
!DataGrid1.Cont rolStyle.Reset( );
!DataGrid1.Cell Spacing = 0;
!
!then the datagrid is rendered as a table and the
!style="border-collapse:collap se;" comes back again!
!
!How can I get rid of it?
!
!
!Thanks
!
!Vaclav
!
!
!
!

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
29016
by: Frostillicus | last post by:
I work with Interwoven TeamSite in an environment where I do not have access to customise the default stylesheet, so the only option available to me is to specify an additional stylesheet wherein I can add further customisations. My problem is that the master stylesheet, which I can not edit or remove, includes a CSS selector for all input elements such that the border is thus: border: 1px #cccccc solid;
0
1391
by: TusharP | last post by:
Hi Friends, I have one form having border style none. (Form have irregular shape) This form has number of Dropdown, Textbox and Labels. When Minimized button I resize form to some small value. Now I want to apply my own Scrolled control to see all controls in minimized state. I attach my scrollbar (having diff. look n feel) How to scroll these form controls. Need urgent help.... Thanx in Advance. Tushar P.
2
5621
by: Alvo von Cossel I | last post by:
hi, sorry about the first message; i accidentally clicked post. anyway, i want to make a modern looking app like quicktime that has not got that bar at the top with the title in it and the controlbox. i have put a no border style property on the form and have replace the control box with a menustrip. i asked a friend how to make my form moveable and he could only make my form moveable if you click the form, not the menustrip. how do...
0
1065
by: Job Lot | last post by:
How can I make border of Panel control look similar to xp style textbox border style?
1
4195
by: Patrick | last post by:
Hello, I want to change the border of an asp-dropdownlist via C#. With ddl.CssClass = "empty"; I want to change the border of the DDL to red, but it works only in Firefox not in Internet Explorer. Why not? The according stylesheet looks like this:
1
15319
by: Armin Gajda | last post by:
Hi, I have the following problem: An input field get a border assigned by a style class (e.g. 2px solid red). When the field gets the focus, we set the border to green. element.style.border = "2px solid green"; When the field looses the focus, the border should change back to red.
1
1231
by: Coder | last post by:
Is there a way to change a forms border style at run time?
1
1352
by: Mark Rae | last post by:
Hi, Have been modifying a piece of JavaScript I found on the net which completely prevents the Google AutoFill Toolbar from doing its stuff... Got that working now but, while I was debugging it, I noticed that every field that the Google Toolbar turned yellow also had its border style changed... Seems that this is a standard "feature"... If you specify an <asp:TextBox>'s BackColor property, that also changes its border style - has...
2
8206
by: Randy | last post by:
I'm trying to loop through all of the textboxes on my form and change some of their properties. I'm stuck on changing the border style to none. Here is my code: Dim c As Control For Each c In Me.Controls If TypeOf c Is TextBox Then c.Enabled = False c.BorderStyle = None End If
2
1612
by: DAXU | last post by:
Hi, What I found is that when my form set border style to none, I can't right click and close the program as I can when the border is set to fixed single. (i.e., by right click the program in the toolbar and click close there). But I do need the form to by borderless, so is there any chance that I can still close the program with a right click? Now I am using task manager to close it.
0
8347
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8792
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8694
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8457
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8571
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4143
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1585
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.