473,414 Members | 1,951 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,414 software developers and data experts.

Better Way???

I am new to asp.net. Is there a better way to do the following code?

Dim Cell1 As New System.Web.UI.WebControls.TableCell
Dim Cell2 As New System.Web.UI.WebControls.TableCell
Dim Cell3 As New System.Web.UI.WebControls.TableCell
Dim Cell4 As New System.Web.UI.WebControls.TableCell

Cell1.Text = "cell1"
Cell2.Text = "cell2"
Cell3.Text = "cell3"
Cell4.Text = "cell4"

Table1.Rows.Add(New System.Web.UI.WebControls.TableRow)

Table1.Rows(Table1.Rows.Count - 1).Cells.Add(Cell1)
Table1.Rows(Table1.Rows.Count - 1).Cells.Add(Cell2)
Table1.Rows(Table1.Rows.Count - 1).Cells.Add(Cell3)
Table1.Rows(Table1.Rows.Count - 1).Cells.Add(Cell4)

Cell1.Dispose()
Cell2.Dispose()
Cell3.Dispose()
Cell4.Dispose()

I have a recordset that I am trying to add to display on the page. I
already have a table with some data in it. I am trying to append the
new data to. If there is a better way of doing this I would greatly
appreciate it.

Thanks again

Nov 20 '05 #1
1 1189
You should consider moving away from the "building tables manually to
display data" paradigm of classic ASP and move towards the dynamic features
of Web Form controls and ADO.NET.

I wouldn't do any of what you have here (and, by the way, there is no need
for you to call dispose on a cell object - - only objects that use unmanaged
resources would need a dispose call).

You can populate a DataSet (no more recordsets) with your data and simply
bind an ASP.NET DataGrid control to that DataSet. No manual table creation
necessary.

-Scott

"unwantedspam" <un**********@mchsi.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I am new to asp.net. Is there a better way to do the following code?

Dim Cell1 As New System.Web.UI.WebControls.TableCell
Dim Cell2 As New System.Web.UI.WebControls.TableCell
Dim Cell3 As New System.Web.UI.WebControls.TableCell
Dim Cell4 As New System.Web.UI.WebControls.TableCell

Cell1.Text = "cell1"
Cell2.Text = "cell2"
Cell3.Text = "cell3"
Cell4.Text = "cell4"

Table1.Rows.Add(New System.Web.UI.WebControls.TableRow)

Table1.Rows(Table1.Rows.Count - 1).Cells.Add(Cell1)
Table1.Rows(Table1.Rows.Count - 1).Cells.Add(Cell2)
Table1.Rows(Table1.Rows.Count - 1).Cells.Add(Cell3)
Table1.Rows(Table1.Rows.Count - 1).Cells.Add(Cell4)

Cell1.Dispose()
Cell2.Dispose()
Cell3.Dispose()
Cell4.Dispose()

I have a recordset that I am trying to add to display on the page. I
already have a table with some data in it. I am trying to append the
new data to. If there is a better way of doing this I would greatly
appreciate it.

Thanks again

Nov 20 '05 #2

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

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
3
by: Muhd | last post by:
<usualDisclaimer>Please forgive me if this is in the wrong group, and if so, what is the right group.</usualDisclaimer> Let me start off by first saying im a newb. Ok, with that out of the way I...
24
by: Faith Dorell | last post by:
I really don´t like C.You can write better programs in BASIC than in C, if you don´t like this language. I don´t understand how C became so popular, although much better programming languages...
43
by: Rob R. Ainscough | last post by:
I realize I'm learning web development and there is a STEEP learning curve, but so far I've had to learn: HTML XML JavaScript ASP.NET using VB.NET ..NET Framework ADO.NET SSL
33
by: Protoman | last post by:
Which is better for general-purpose programming, C or C++? My friend says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
22
by: JoeC | last post by:
I am working on another game project and it is comming along. It is an improvment over a previous version I wrote. I am trying to write better programs and often wonder how to get better at...
19
by: Alexandre Badez | last post by:
I'm just wondering, if I could write a in a "better" way this code lMandatory = lOptional = for arg in cls.dArguments: if arg is True: lMandatory.append(arg) else: lOptional.append(arg)...
23
by: mike3 | last post by:
Hi. (posted to both newsgroups since I was not sure of which would be appropriate for this question or how specific to the given language it is. If one of them is inappropriate, just don't send...
20
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got the following C++ code. The first routine runs in...
3
by: Ryan Liu | last post by:
Hi, Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than synchronous I/O? At least as good? When I don't concern about easy or difficult to write code, should I always...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.