473,725 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to set Backcolor in cells of Dynamically Created Tables in ASP.NET

144 New Member
Hai Friends,

I have the following code for Dynamically Created Tables, I have created the panel in the webform.......

Dim tab5 As New Table
Dim row1 As New TableRow

Dim cell1 As New TableCell
cell1.Text = "Java"
row1.Cells.Add( cell1)


Dim cell2 As New TableCell
cell2.Text = "C++"
row1.Cells.Add( cell2)

tab5.Rows.Add(r ow1)
panel1.Controls .Add(tab5)

it works properly , But the Proplem is i cant give backcolor for Cell in this format #FFFFFFF,#66CCF F etc

when i give like this

cell2.Backcolor ="#FFFFFFF"

it shows as Error....

I have to give color in this Format #FFFFFFF,#66CCF F etc

Pl Help Me

Thanks in Advance........ ...........

Posted Date :- 29 Feb 2008

Davidson
Feb 28 '08 #1
5 2982
Plater
7,872 Recognized Expert Expert
Those numbers are just the hex version of your color. (Red Green Blue values). Just create a Color object using those values and assign it to the back color.
Feb 28 '08 #2
balabaster
797 Recognized Expert Contributor
Those numbers are just the hex version of your color. (Red Green Blue values). Just create a Color object using those values and assign it to the back color.
Alternatively you could use something akin to:
Expand|Select|Wrap|Line Numbers
  1. MyTable.Row(n).BackColor = System.Drawing.ColorTranslator.FromHtml("#C0C0C0")
Should do the job...
Feb 28 '08 #3
SharpDeveloper
12 New Member
Hi Davidson
Try this out
cell2.BackColor = Drawing.ColorTr anslator.FromHt ml("#C3E4F9")
Hope this helps

Hai Friends,

I have the following code for Dynamically Created Tables, I have created the panel in the webform.......

Dim tab5 As New Table
Dim row1 As New TableRow

Dim cell1 As New TableCell
cell1.Text = "Java"
row1.Cells.Add( cell1)


Dim cell2 As New TableCell
cell2.Text = "C++"
row1.Cells.Add( cell2)

tab5.Rows.Add(r ow1)
panel1.Controls .Add(tab5)

it works properly , But the Proplem is i cant give backcolor for Cell in this format #FFFFFFF,#66CCF F etc

when i give like this

cell2.Backcolor ="#FFFFFFF"

it shows as Error....

I have to give color in this Format #FFFFFFF,#66CCF F etc

Pl Help Me

Thanks in Advance........ ...........

Posted Date :- 29 Feb 2008

Davidson
Feb 28 '08 #4
Plater
7,872 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. System.Drawing.ColorTranslator.FromHtml()
  2.  
Learn something new everyday.
Feb 28 '08 #5
balabaster
797 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. System.Drawing.ColorTranslator.FromHtml()
  2.  
Learn something new everyday.
;o) Glad to inform...hehe
Feb 28 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7724
by: Finn Newick | last post by:
By defining a style as follows: @media aural, handheld {td.layout {display:block;}} I'm hoping to linearise layout tables when viewed by screenreaders and handheld devices (it is also be in some selectable user preferences). This works as intended in Netscape 7 - all the cells stack vertically above each other nicely, but not in Internet Explorer 6 where the only display property that td will respond to seems to be 'none'.
0
8681
by: Chris Powell | last post by:
I am using Excel/Access 2000 and have two large Excel files (25,000 rows each) that I wish to create linked tables in Access rather than importing into Access. The two source Excel files change frequently, so I want to: A) prompt the user, using a custom form, for the specific Excel files to be linked; B) create the links dynamically; C) insert the linked tables into a select query grid and include the SQL statement in the VBA...
4
14159
by: Rob Meade | last post by:
Hi all, I'm desperately trying to get this to work and I just cant do it - new to ASP.net - probably the reason! I'm using visual studio for this - I have this in the html page : <asp:Table id="Table1" runat="server"></asp:Table> there is other code too but I believe this to be the relevant part...
5
36876
by: Richard Dixson | last post by:
I created a new C# web application. Basically all I am trying to do is create a table that consists of a few rows with two columns in each. And then to set those columns to text values from my code behind. However I am not able to do this at all, I am going about this wrong, I think and need guideance. If this was just straight HTML I would do this: <table> <tr><td>field 1</td><td>value 1 set by code behind</td></tr>
1
1708
by: Chris | last post by:
Hi, I am trying to set a row backcolor based on the value of a cell in my datagrid but it's not working This is what I have Private Sub grdProcessingTitles_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdPro.ItemDataBound
5
3040
by: mrid via DotNetMonster.com | last post by:
hi. im exporting data from a vb form to excel. i am able to create a new excel file, save and edit it without any trouble, but the formatting is giving me hell! i need to be able to show certain cells in bold, with underlining etc. i dont understand how, but in the following code, the instruction for bold gets picked up for all the cells (even when i specify font.bold = false), and the underlining is haphazardly used. the font colour...
4
31999
by: Paul | last post by:
Hello All, I have been trying to figure out how to set the BackColor of individual cells in a DataGridView. I found the following solution in a VB usenet group DataGridView1.Item(ColumnIndex, RowIndex).Style.BackColor = Color DataGridView1.Item(ColumnIndex, RowIndex).Style.ForeColor = Color or
4
2200
by: .Net Sports | last post by:
I need to dynamically assign a datalist attribute upon a helper function receiving data from a querystring. If a user picks a certain region, i need the datalist to display its back color, or any of its other objects , as a certain color or css style <HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle> ....doesnot work as a Parser error renders: Content ('<HeaderStyle
1
1132
by: Ayushi | last post by:
Hello, I have dynamically created fields in a gridview and bound the grid.But I am not able to access the cells in those fields.Can anybody help me out with this. Thankyou.
0
8872
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
8747
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9392
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...
1
9162
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
9091
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
5997
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();...
1
3211
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
2619
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2150
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.