|
-
Sep 12th, 2006, 10:15 AM
#1
Thread Starter
Fanatic Member
Programatically access an HTML table control
How do I programatically access an HTML table control from within VB? I actually want to access one of the table headers and set the text dependent on some logic.
I have given the table an ID="tbJobs" and the table header cell an ID="tbCustomField".
Any ideas?
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Sep 12th, 2006, 10:59 AM
#2
Re: Programatically access an HTML table control
In the CodeBehind...
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.tbJobs.Rows(0).Cells(0).Text = "My Table Header"
'...
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 12th, 2006, 11:23 AM
#3
Re: Programatically access an HTML table control
You also have to give the table a runat attribute.
<table id="abc" runat="server"...>
Note, however. Once you make this change in the html view, go to design view, save the page, and THEN go into the codebehind.
-
Sep 13th, 2006, 02:35 AM
#4
Thread Starter
Fanatic Member
Re: Programatically access an HTML table control
Well, here's the rub. When i give it the runat="server" attribute, it complains that it can't convert a repeater control into a table header. This is because I am using an HTML table to format data displayed with a repeater control. It's kind of embedded in my HTML table. And it doesn't like it when I set the table to run at the server...
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Sep 13th, 2006, 04:20 AM
#5
Re: Programatically access an HTML table control
Ah, you see, that was a bit of important information: The table is part of the template of a repeater control. 
You need to get the repeater's ItemDataBound event. It's in there that you can check to see, first, the type of the row you are looking at (It could be ListItemType.Header, .Item, .Footer), and then if that condition is met, do a .FindControl() on the EventArg parameter of the event. (e.FindControl("tableid"))
-
Sep 13th, 2006, 04:25 AM
#6
Thread Starter
Fanatic Member
Re: Programatically access an HTML table control
And using the ItemDataBound event...my HTML table does not need to be runat="server"?
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Sep 13th, 2006, 04:36 AM
#7
Re: Programatically access an HTML table control
No, it doesn't. Because the table will then only exist as part of the control collection of the item/header/footer in your repeater control. It's the same for a datagrid and I can vaguely recall talking to you about a similar situation back when...
-
Sep 13th, 2006, 04:44 AM
#8
Thread Starter
Fanatic Member
Re: Programatically access an HTML table control
Are you accusing me of having a short memory? Why you...you...whatever you name is!
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|