473,324 Members | 2,248 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,324 software developers and data experts.

HT retrieve values in html table from codebehind

I have hit a wall with not being able to enumerate the items collection in a
table row.

given:

<table runat=server id=table1>
<tr>
<td id=AAA>HowToReferenceThisValue</td>

etc...

from code behind, how can I iterate thru / parse the html table to get AAA's
text ='HowToReferenceThisValue'
Mar 10 '07 #1
4 6274
HtmlTableCell cell = table1.Controls[0].Controls[0] as HtmlTableCell;

cell.InnerHtml would evaluate to 'HowToReferenceThisValue'
cell.ID would evaluate to server side id (AAA here)
cell.ClientID would evaluate to client-side id (which may be different
than server side depending on nesting level)

To access some html attribute other than id, use
cell.Attributes["NameOfAttribute"]

Iteration via IEnumerable would be like following (above mentioned
properties can be acessed after casting to HtmlTableRow or
HtmlTableCell if needed)

foreach (Control row in table1.Controls)
{
foreach (Control cell in control.Controls)
{
....
}
}

Mar 10 '07 #2
HtmlTableCell cell = table1.Controls[0].Controls[0] as HtmlTableCell;

cell.InnerHtml would evaluate to 'HowToReferenceThisValue'
cell.ID would evaluate to server side id (AAA here)
cell.ClientID would evaluate to client-side id (which may be
different
than server side depending on nesting level)
To access some html attribute other than id, use
cell.Attributes["NameOfAttribute"]
Iteration via IEnumerable would be like following (above mentioned
properties can be acessed after casting to HtmlTableRow or
HtmlTableCell if needed)
foreach (Control row in table1.Controls)
{
foreach (Control cell in row.Controls)
{
....
}
}

Mar 10 '07 #3
HtmlTableCell cell = table1.Controls[0].Controls[0] as HtmlTableCell;

cell.InnerHtml would evaluate to 'HowToReferenceThisValue'

++++++++++++++++++++++++++++++++++++++++++++++++++
Problem:
cell.InnerHtml is not a property of cell

further,
table1.Controls[0].Controls[0]
( System.Web.UI.HtmlControls.HtmlTableCell )
only lists the attributes, not the item
++++++++++++++++++++++++++++++++++++++++++++++++++

cell.ID would evaluate to server side id (AAA here)
cell.ClientID would evaluate to client-side id (which may be
different
than server side depending on nesting level)
To access some html attribute other than id, use
cell.Attributes["NameOfAttribute"]

Iteration via IEnumerable would be like following (above mentioned
properties can be acessed after casting to HtmlTableRow or
HtmlTableCell if needed)

++++++++++++++++++++++++++++++++++++++++++++++++++
Problem:
as far as I know, the items collection of
System.Web.UI.HtmlControls.HtmlTableCell is not enumerable
++++++++++++++++++++++++++++++++++++++++++++++++++

foreach (Control row in table1.Controls)
{
foreach (Control cell in row.Controls)
{
....
}
}
Mar 10 '07 #4
++++++++++++++++++++++++++++++++++++++++++++++++++
Problem:
cell.InnerHtml is not a property of cell
http://msdn.microsoft.com/library/de...rhtmltopic.asp

And HtmlTableCell inherits from HtmlContainerControl.
So yes, InnerHtml is a property of cell (HtmlTableCell to which I had
cast variable 'cell').
further,
table1.Controls[0].Controls[0]
( System.Web.UI.HtmlControls.HtmlTableCell )
only lists the attributes, not the item
Attributes is an AttributesCollection
http://msdn.microsoft.com/library/de...butestopic.asp
which implements Item
http://msdn.microsoft.com/library/de...classtopic.asp
So yes, you can use Item (on Attributes of course).
Problem:
as far as I know, the items collection of
System.Web.UI.HtmlControls.HtmlTableCell is not enumerable
Problem :)
1) HtmlTableCell does not have items collection (as you yourself said
few lines ago).
2) Whichever object has Items, that is enumerable, for the type of
unit of items.
3) I had enumerated Controls collections (not Items), which is, yes,
also enumerable
http://msdn.microsoft.com/library/de...classtopic.asp

Why don't you please compile the code first and then comment.
I have compiled it and everything works as expected.

Mar 10 '07 #5

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

Similar topics

11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
4
by: tma | last post by:
I'm trying to retrieve values for my HTML from the Codebehind file and I'm unclear how to accomplish this. For example: <INPUT TYPE="hidden" NAME="amount" VALUE="xx"> How do I populate the...
1
by: Coach | last post by:
Is it possible to reference a html table control through code in C#? I want to be able to make a table visible/hidden. -- Coach
0
by: Manesh | last post by:
I have an oracle function which return an oracle user defined table type. How to retrieve values from this type (function from a vb.net application ? Here is my sample code Please help create or...
2
by: GD | last post by:
Hi, I am trying to get values from table cells and textboxes that have same component names in a table after posting to the same page. Javascript is able to get the component values while the...
1
by: san1014 | last post by:
Hi I have a table SQL> select * from nodes; NODE_ID NODE_NAME -------------------- ------------------------------ N1 Kothhapet N2 Nagole...
0
by: Jeff | last post by:
hey asp.net 3.5 I'm developing a webportal which need to access a webpage of a external system. The external webpage contain a table which I want to retrieve the values from.. it is a html...
8
by: James Kimble | last post by:
Yeah I'm sure this is a stupid question. I've got a javascript source file with functions (creates a bar graph) I want to call from inside an html table cell so that the graph appears in the...
16
by: BaseballGraphs | last post by:
Hello, I am trying to filter an HTML table by div value using javascript. Here is my table in HTML: <table> <tr> <td><div align="center">1</div></td> <td><div align="left"...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.