|
 |
aspx_beginners thread: Dynamically setting a value in a Table Cell.
Message #1 by "Colin Drummond" <cdrummond@s...> on Tue, 5 Nov 2002 00:33:00
|
|
Using VB in Visual Studio designer, I created a table web control
with 3 rows and 2 columns. I set the text values in the
properties screen.
Now I want to set individual cells in the Page_Load event
in the code behind page.
For example, Row(1).Column(1) = "5", or
Row(2).Column(0) = someintegervariable
Where in the documentation does one find the appropriate
syntax for performing such an operation?
What is the best way to do this?
Thanks - Colin
------------------
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 5 Nov 2002 17:40:47 +1100
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Colin Drummond" <cdrummond@s...>
Subject: [aspx_beginners] Dynamically setting a value in a Table Cell.
: Using VB in Visual Studio designer, I created a table web control
: with 3 rows and 2 columns. I set the text values in the
: properties screen.
:
: Now I want to set individual cells in the Page_Load event
: in the code behind page.
:
: For example, Row(1).Column(1) = "5", or
: Row(2).Column(0) = someintegervariable
:
: Where in the documentation does one find the appropriate
: syntax for performing such an operation?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Table web control has a "Rows" property which returns a
TableRowsCollection which contains the TableRow objects in your table. Each
TableRow has a Cells property that returns a TableCellCollection object,
which in turn contains each of the TableCell objects in that row. You can
set the .Text property of an individual TableCell object.
How to do this would probably depend on whether you wanted to set just 1, or
2 cells, or you want to loop through them setting all the values, or
whatever.
Where in the docs do you look this up? Underneath each class (ie goto
System.Web.UI.WebControls and goto Table, and work your way downward...
you could do:
myTable.Rows.Item(index).Cells.Item(Index).Text = "myString"
to just set an particular cell.
Cheers
Ken
Message #3 by "Colin Drummond" <cdrummond@s...> on Wed, 6 Nov 2002 12:08:39
|
|
Thanks Ken
myTable.Rows.Item(index).Cells.Item(Index).Text = "myString"
is just what I need to know.
The microsoft documentation just had me going round in circles, I don't
think I would ever have found the correct syntax.
Thanks again...
|
|
 |