dynamically created table not rendering on asp.net web page

Last post 08-12-2008 12:48 PM by Princy Alexander. 5 replies.

Sort Posts:

  • dynamically created table not rendering on asp.net web page

    08-12-2008, 8:11 AM

    Hi,

            I am creating a table during form load with the following code but cant render it

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

              ViewState.Add(ViewState.Count, "This is column 1 text")

             call rebuildtable()

    End Sub

    protected sub rebuildtable ()

            Dim Icount1 As Integer

            Dim strtext As String

            Dim table1 As New Table

            For Icount1 = 0 To (ViewState.Count - 1)

                      Dim rownew As New TableRow

                      strtext = ViewState(Icount1)

                      Dim cellnew As New TableCell

                      cellnew.Text = strtext

                      rownew.Cells.Add(cellnew)

                      table1.Rows.Add(rownew)

            Next

            table1.Width = 1300

            table1.Height = 800

            table1.Visible = True

    end sub 

    Please help

    Regards

    Sanjish 

     

     

  • Re: dynamically created table not rendering on asp.net web page

    08-12-2008, 9:04 AM
    • Contributor
      2,160 point Contributor
    • Talib_dotnet
    • Member since 01-31-2008, 11:02 AM
    • Riyadh , Saudi Arabia
    • Posts 457

    Hi   Sanjish,

    Although  you  are dynamically  creating  the  table  but  you  are not  adding  it  to  the  form ....

    for  eg.,       Dim tt As New TextBox()
                      Me.form1.Controls.Add(tt)

    Hope  this  helps  you....

    Click "Mark As Answer" if it helped you.


    TALIB ALI KHAN
    Software Engineer / Consultant
    MCTS


    Welcome to TALIB's World | My BLOG | More Asp.net Articles



  • Re: dynamically created table not rendering on asp.net web page

    08-12-2008, 12:13 PM
    • Star
      8,817 point Star
    • lspence
    • Member since 11-01-2006, 2:12 PM
    • United States
    • Posts 1,358

    SANJISH KUMAR:

    table1.Width = 1300

            table1.Height = 800

            table1.Visible = True
     

    Just change the above to:

    table1.Width = 1300
    table1.Height = 800
    table1.Visible = True

    Page.Controls.Add(table1)
      
    My Blog
    http://Lspence.blogspot.com

    (Please MARK this post as ANSWERED, if you find it helpful)
  • Re: dynamically created table not rendering on asp.net web page

    08-12-2008, 12:15 PM

    Hi Talib,

                  I tried adding the table to the forms control collection but I have a peculiar problem here. The page where i want to display the table contains a paypal 'Buy Now' button with the following html and i am not supposed to change it

     

    <form target = "paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">

    <input type="hidden" name="cmd" value="_xclick"/>

    <input type="hidden" name="business" value="support@profitfromit.co.in"/>

    <input type="hidden" name="item_name" value="PRICE_LISTING"/>

    <input type="hidden" name="amount" value="<%Response.Write(Mamount)%>"/>

    <input type="hidden" name="no_shipping" value="0"/>

    <input type="hidden" name="no_note" value="1"/>

    <input type="hidden" name="currency_code" value="USD"/>

    <input type="hidden" name="lc" value="IN"/>

    <input type="hidden" name="bn" value="PP-BuyNowBF"/>

    <input type="hidden" name="return" value="http://profitfromit.co.in"/>

    <input type="hidden" name="notify_url" value="http://profitfromit.co.in/home.aspx"/>

    <input type="image" border="0" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!" style="z-index: 100; left: 539px; position: absolute; top: 367px"/>

    <img alt="" src="https://www.paypal.com/en_US/i/scr/pixel.gif" border="0" width="1" height="1"/>

    </form>

     

    Is it because i cant have a runat="server" attribute  in the form tag . If that is the case how do i get over this problem ? as i have to show a table which displays the items bought by my customer

    Many thanks

    Regards

    Sanjish

  • Re: dynamically created table not rendering on asp.net web page

    08-12-2008, 12:23 PM
    • Star
      8,817 point Star
    • lspence
    • Member since 11-01-2006, 2:12 PM
    • United States
    • Posts 1,358

    Place your table within a DIV and then position the DIV where you'd like it to be.

    My Blog
    http://Lspence.blogspot.com

    (Please MARK this post as ANSWERED, if you find it helpful)
  • Re: dynamically created table not rendering on asp.net web page

    08-12-2008, 12:48 PM
    Answer

    Create the table at design time without any rows.

    And dynamically add rows to the table which is already existing in the form.

    Thanks,
    Princy

    Kindly mark it as answered if it really helps u.
Page 1 of 1 (6 items)