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

Button in dynamic table cell

How do I get a dynamically created button control to appear in a dynamically
created table cell?

Here's what I've tried:
While objDR1.Read()
Dim objButton As New Button
Dim objTableRow As New TableRow
Dim objTableCell As New TableCell
Dim strURL As String = objDR1("URL").ToString()

objButton.Text = "edit"
objButton.Visible = True
objButton.Width = New Unit(60)
objButton.Height = New Unit(20)

AddHandler objButton.Click, AddressOf DynamicButtonClick

objTableCell.Controls.Add(objButton)
objTableCell.Text = objMember.AuthorizeGetPageRoles(strURL).Replace(", ",
"<br>")
objTableRow.Cells.Add(objTableCell)
objTableCell = New TableCell
objTableCell.Text = objDR1("DisplayName").ToString()
objTableRow.Cells.Add(objTableCell)
objTableCell = New TableCell
objTableCell.Text = strURL
objTableRow.Cells.Add(objTableCell)
tblMenuSecurity.Rows.Add(objTableRow)
End While

This does not work: the buttons do not show up in the table cells (in fact,
they don't show up at all, anywhere).

Ideas?

TIA,
Owen
Dec 15 '05 #1
1 3342
OK, I feel silly now. Note that in addition to adding to the controls
collection of the table cell, I also try to set the text property. This
must clear any other events that tried to set text in the cell. By removing
the objTableCell.Text = ... line of code, the buttons show up and operate as
expected.

Cheers,
Owen

"Owen Mortensen" <oj*********@acm.org> wrote in message
news:Om**************@TK2MSFTNGP15.phx.gbl...
How do I get a dynamically created button control to appear in a
dynamically created table cell?

Here's what I've tried:
While objDR1.Read()
Dim objButton As New Button
Dim objTableRow As New TableRow
Dim objTableCell As New TableCell
Dim strURL As String = objDR1("URL").ToString()

objButton.Text = "edit"
objButton.Visible = True
objButton.Width = New Unit(60)
objButton.Height = New Unit(20)

AddHandler objButton.Click, AddressOf DynamicButtonClick

objTableCell.Controls.Add(objButton)
objTableCell.Text = objMember.AuthorizeGetPageRoles(strURL).Replace(", ",
"<br>")
objTableRow.Cells.Add(objTableCell)
objTableCell = New TableCell
objTableCell.Text = objDR1("DisplayName").ToString()
objTableRow.Cells.Add(objTableCell)
objTableCell = New TableCell
objTableCell.Text = strURL
objTableRow.Cells.Add(objTableCell)
tblMenuSecurity.Rows.Add(objTableRow)
End While

This does not work: the buttons do not show up in the table cells (in
fact, they don't show up at all, anywhere).

Ideas?

TIA,
Owen

Dec 15 '05 #2

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

Similar topics

6
by: Trevor Hartman | last post by:
Hi, I need to refer to my objects dynamically. I have a 7 table cells (sunCell, monCell, tueCell....). I am looping through some data, checking its date and adding it to the correct cell. I...
3
by: David Whitney | last post by:
All: I have a control that renders a table. As the table is rendered, each row in the table is constructed by creating a run-time (dynamic) object that is derived from an HtmlTableRow. The row...
1
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new...
0
by: Pat Sagaser via .NET 247 | last post by:
I'm using a repeater with a dynamic template. I don't know the fields to display (or how many) until runtime. I have everything working except for linking Button events to the repeaters ItemCommand...
1
by: RSB | last post by:
Hi Everyone, I have a collection of items and i am generating a Dynamic Table based on this Collection and i am also adding a Remove Linkbutton at the End for Each Row. I have created a...
3
by: Wang | last post by:
Here is the code for a webcontrol, quite simple: ------------------------------------------------------------------------------------------------------------- <%@ Control Language="c#"...
2
by: dschectman | last post by:
This appears to be a feature of IE JavaScript. I am running IE 6.0 with the latest patches from Microsoft. Are there any workarounds other than re-coding the source HTML to place all the...
1
by: Bart Lateur | last post by:
I'm trying to put a utton at the bottom (right) of a TD cell, irrespective of what else is in there. Usually, with other HTML block elements, we're told to use position: relative on the...
0
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.