Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 18th, 2006, 09:49 PM
Authorized User
 
Join Date: Aug 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Building table rows dynamically

Howdy,

I am trying to build a table row dynamically from a table that I positioned on a web form. The table name is "MarketTable" Here is the code:

Partial Class Default2
    Inherits System.Web.UI.Page

    Private WithEvents MarketTable As System.Web.UI.WebControls.Table

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim tr As New TableRow

        MarketTable.Rows.Add(tr)
    End Sub
End Class

When I run the code, I get the following error:
Use the "new" keyword to create an object instance.

Any suggestions?



nikotromus
__________________
nikotromus
 
Old January 21st, 2006, 03:00 PM
Authorized User
 
Join Date: Aug 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I fugured out the problem. My anchor on the web page was not in the proper format. Here is the successful anchor I used. By doing this, it allowed me to access the properties of the table in the code.

<asp:Table ID ="MarketTable" cellpadding="3" cellspacing="3" style="z-index: 102; left: 302px; position: absolute; top: 107px" runat="server"></asp:Table>

Before, I simply creating a table on the page, through the interface tools. That didn't work. This anchor looks like this:

    <table id="suckit">
        </table>

This is the third straight post I've made on p2p.wrox forums with no reply. I'm starting to get worried about this place.
Ryan


nikotromus
 
Old January 21st, 2006, 11:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Hi nikotromus,
I use this forum heaps and have always found the replies to be prompt and very helpful.
But there are a couple of things that make it easier for people to reply.

1) Use the forum closest to your needs, in this case I feel you would have had a better response from an ASP.NET forum rather than general .NET .
2) Explain your problem in its entirity, in your case the html for the table would have provided an instant response in the ASP.NET forum, as with any controls on a ASP.NET page they must be identifies as ASP.NET controls and not HTML controls and also must have the runat="server" attribute as you are now aware.

Hope you have better luck next time.
Rod

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to dynamically modify a table... roopesh ASP.NET 1.0 and 1.1 Basics 9 January 16th, 2007 12:05 PM
Dynamically adding DataGrid rows lepreston ASP.NET 1.x and 2.0 Application Design 3 November 22nd, 2006 04:33 AM
building crystal report table programmatically khaled_mm VB Components 1 October 6th, 2006 02:26 AM
dynamically create table rows onChange of select crmpicco Classic ASP Basics 0 August 18th, 2005 07:01 AM
Chapter 8: Results Table not building Steve Rosenthal BOOK: Beginning Access VBA 1 September 7th, 2004 06:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.