473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Trying to get started with tables...

I've been attempting to find the answer, but don't know what to search for.
If someone could get me started, I can figure the rest out.

I'm using visual web 2005 with vb.

The following works to change the background color on a table called
"table1"

Table1.BackColor = Drawing.Color.Blue

I would like to programatically change the background color on a row (or
column or both) within that table.
Could someone point me in the right direction.

Thanks

Jeff
--
Posted via a free Usenet account from http://www.teranews.com

Dec 28 '06 #1
4 1156
Hi Jeff,

I assume you're referring to <asp:Table(System.Web.UI.WebControls.Table).
Let me know if this is not the case.

You could easily use Table.Rows(index) to get a reference to individual row
(of type TableRow). From the TableRow reference, you can use
TableRow.Cells(index) to get a reference to individual cell (of type
TableCell). Both of them also have a property named BackColor which can let
you set their background color.

I've written following code snippet to demonstrate how to change a row or
column's background color:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
' Add some rows/columns to the table
For i As Integer = 1 To 10
Dim tr As New TableRow
For j As Integer = 1 To 10
Dim td As New TableCell
td.Text = i.ToString + "." + j.ToString()
tr.Cells.Add(td)
Next
table1.Rows.Add(tr)
Next
' change third row's background color
table1.Rows(2).BackColor = Drawing.Color.Blue

' change third column's background color
' since the table is row-oriented, we need to set the cell
row-by-row
For i As Integer = 0 To table1.Rows.Count - 1
table1.Rows(i).Cells(2).BackColor = Drawing.Color.Gray
Next
End Sub
Hope this helps.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 28 '06 #2

"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:Xl**************@TK2MSFTNGHUB02.phx.gbl...
Hi Jeff,

I assume you're referring to <asp:Table>
(System.Web.UI.WebControls.Table).
Let me know if this is not the case.
Yes, I am referring to the above and understand your code example. I'm still
new to this, however, and can't figure out one last (small) thing. If I'm
working with a .aspx file in the design view of visual web 2005 with the
code-behind file .aspx.vb and if I create a table using the graphical
interface of the .aspx file by going to the layout insert table menu, and
subsequently give it the ID of "table1," the code below does not work, as
it apparently does not refer to the table I just created with the graphic
interface.

table1.Rows(2).BackColor = Drawing.Color.Blue

if I first declare table1 in the following manner, it still doesn't work
(when placed above the code listed above), but it now does not indicate an
error - when the thing is run, however, nothing happens.

Dim table1 As New Table

I know that this is certainly basic, but I'm not sure I understand how to
properly link the table in the DUI's design view and the vb code in the
codebehind file so that it can be programmatically manipulated.

Can you explain further?

Jeff
--
Posted via a free Usenet account from http://www.teranews.com

Dec 28 '06 #3

"Jeff" <no**@none.comwrote in message
news:45***********************@free.teranews.com.. .
>
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:Xl**************@TK2MSFTNGHUB02.phx.gbl...
>Hi Jeff,

I assume you're referring to <asp:Table>
(System.Web.UI.WebControls.Table).
Let me know if this is not the case.

Yes, I am referring to the above and understand your code example.

Never mind. I figured it out. ...don't use the layout table from the menu,
use the table from the toolbox.

Thanks.

Jeff

--
Posted via a free Usenet account from http://www.teranews.com

Dec 28 '06 #4
Hi Jeff,

Thanks for the update.

You might want to check out following resources on how to learn ASP.NET:

#INFO: ASP.NET Roadmap
http://support.microsoft.com/kb/305140

#Microsoft ASP.NET QuickStarts Tutorial
http://www.dotnetjunkies.com/quickst...uickstart.aspx

#ASP.NET QuickStart Tutorial
http://quickstarts.asp.net/QuickStar...t/Default.aspx

Please feel free to post in asp.net related newsgroups if you have any
questions when you're learning ASP.NET. You can find all managed newsgroups
list here:

http://msdn2.microsoft.com/en-us/sub.../aa974230.aspx

For ASP.NET related questions, please use following newsgroups:

microsoft.public.dotnet.framework.aspnet
microsoft.public.dotnet.framework.aspnet.buildingc ontrols
microsoft.public.dotnet.framework.aspnet.caching
microsoft.public.dotnet.framework.aspnet.datagridc ontrol
microsoft.public.dotnet.framework.aspnet.mobile
microsoft.public.dotnet.framework.aspnet.security
microsoft.public.dotnet.framework.aspnet.webcontro ls
microsoft.public.dotnet.framework.aspnet.webservic es
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 28 '06 #5

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

Similar topics

3
by: EasyRider41 | last post by:
I am trying to merge to scripting samples I for on a source code web site and having limited luck. Then first one is called Zebra Tables witch colors alternate rows of a table to look beter. The...
2
by: Belinda | last post by:
Hi. I am just getting started with DB2's spatial extender and could really use some help. Pointers to good docs or examples are welcome. I am using DB2 version 8 on Sun. I have a database of...
1
by: Leif K-Brooks | last post by:
I've been programming web applications in PHP/MySQL for a few years. It's worked decently, but I've been getting annoyed with the lack of more advanced features lately. After some reading, I've...
2
by: Steve Gollery | last post by:
I installed Postgres 8 beta 3 on an XP box, with Postgres running as a service. TaskManager tells me that postgres and postmaster are both running. Using pgAdmin III, I can connect to the server...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
12
by: Jim Anderson | last post by:
This is my first attempt at XML documentation. I'm trying to get started with docbook so I can put a set of documentation into docbook tags. I'm using 'XML In A Nutshell" and "DocBook The...
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
1
by: Timothy.Rybak | last post by:
I need help designing a database that keeps up with a point system we have here at work. I'll tell you what I know. First, I have a list of all the employee names for a table. Second, for...
1
by: ray2heavy | last post by:
Hey guys, I am getting a "database cant lock table "blah" because it is already in use by another person or process" while trying to delete, then re-populate it. This table is viewed in a subform...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.