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

dynamic object name

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 want to be able to do something like:

string day;
foreach ...
{
day = getShortDay(someDateTime);
[day + "Cell"].Controls.Add(new LiteralControl("put some content in this
cell.."));
}

Is there anyway to do this?

thank you - Trevor
Nov 17 '05 #1
6 3519
Why not just using an enumerator and refer to the tables cell collection?
Once you have a reference to the tablecell object you can add to it's
controls collection.

"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
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 want to be able to do something like:
string day;
foreach ...
{
day = getShortDay(someDateTime);
[day + "Cell"].Controls.Add(new LiteralControl("put some content in this cell.."));
}

Is there anyway to do this?

thank you - Trevor

Nov 17 '05 #2
The table is dynamic, and I just want 7 individual table cells, and create a
new instance every time I have a new row. how would I do an enumerator in
this case??

its like this:
TableRow row = new TableRow();

TableCell sunCell = new TableHeaderCell();
sunCell.Text = "Sun";
TableCell monCell = new TableHeaderCEll();
monCell.Text = "Sun";
.....
.....

foreach (DataInfo DateItem in DataCollection) // loop through the event data
{
[getShortDayName(DataInfo._Date) + "Cell"].Controls.Add(new
LiteralControl("content"));
...
...
...
}

string getShortDayName(DateTime Date)
{
// some code to return short day name as a string
}

with this setup, can I still use enumeration, or does anyone have any other
ideas?

Thanks,
Trevor Hartman

"Jay Pondy" <jp****@mindspring.com> wrote in message
news:bd**********@slb3.atl.mindspring.net...
Why not just using an enumerator and refer to the tables cell collection?
Once you have a reference to the tablecell object you can add to it's
controls collection.

"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
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 want to be able to do something

like:

string day;
foreach ...
{
day = getShortDay(someDateTime);
[day + "Cell"].Controls.Add(new LiteralControl("put some content in

this
cell.."));
}

Is there anyway to do this?

thank you - Trevor


Nov 17 '05 #3
thanks a lot for your help! i've never done enumeration so i'm reading up
on it now.

-Trevor

"Jay Pondy" <jp*****************@web2news.net> wrote in message
news:46*******@web2news.com...
Create the row and then enumerate Sun - Sat adding a cell for each and
at the same time query the data source to see if you need to add a
literal control for that days cell contents.

Trevor Hartman wrote:
The table is dynamic, and I just want 7 individual table
cells, and create a
new instance every time I have a new row. how would I do
an enumerator in
this case??

its like this:
TableRow row = new TableRow();

TableCell sunCell = new TableHeaderCell();
sunCell.Text = "Sun";
TableCell monCell = new TableHeaderCEll();
monCell.Text = "Sun";
....
....

foreach (DataInfo DateItem in DataCollection) // loop
through the event data
{
[getShortDayName(DataInfo._Date) + "Cell"].Controls.Add(new
LiteralControl("content"));
...
...
...
}

string getShortDayName(DateTime Date)
{
// some code to return short day name as a string
}

with this setup, can I still use enumeration, or does
anyone have any other
ideas?

Thanks,
Trevor Hartman

"Jay Pondy" <jp****@mindspring.com> wrote in message
news:bd**********@slb3.atl.mindspring.net...
Why not just using an enumerator and refer to the tables
cell collection?
Once you have a reference to the tablecell object you can
add to it's
controls collection.

"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
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 want to be able to
do something
like:

string day;
foreach ...
{
day = getShortDay(someDateTime);
[day + "Cell"].Controls.Add(new LiteralControl("put
some content in
this
cell.."));
}

Is there anyway to do this?

thank you - Trevor


--
Direct access to this group with http://web2news.com
http://web2news.com/?microsoft.publi...amework.aspnet

Nov 17 '05 #4
ok i read up on enumeration and don't really understand what you mean by
enumerating sun - sat. also, i don't want to loop through my datacollection
98 times, which is how many cells there are. what I am doing now is
creating the table giving each cell a unique ID (date + hour). if you want
to see the table, here it is:
http://www.futureshirts.com/calendar...012:00:00%20AM

wouldn't it be a better idea to just loop through the data once after the
table is created, find the cell that matches the event by date + hour, then
add the event to that cell? the only problem i'm having is referencing the
cell. I could do a FindControl, but I don't really know how to use the
results, since it is a control. I always get the "Object reference not set
to an instance of an object". what do you think?

thanks - trevor
"Jay Pondy" <jp*****************@web2news.net> wrote in message
news:46*******@web2news.com...
Create the row and then enumerate Sun - Sat adding a cell for each and
at the same time query the data source to see if you need to add a
literal control for that days cell contents.

Trevor Hartman wrote:
The table is dynamic, and I just want 7 individual table
cells, and create a
new instance every time I have a new row. how would I do
an enumerator in
this case??

its like this:
TableRow row = new TableRow();

TableCell sunCell = new TableHeaderCell();
sunCell.Text = "Sun";
TableCell monCell = new TableHeaderCEll();
monCell.Text = "Sun";
....
....

foreach (DataInfo DateItem in DataCollection) // loop
through the event data
{
[getShortDayName(DataInfo._Date) + "Cell"].Controls.Add(new
LiteralControl("content"));
...
...
...
}

string getShortDayName(DateTime Date)
{
// some code to return short day name as a string
}

with this setup, can I still use enumeration, or does
anyone have any other
ideas?

Thanks,
Trevor Hartman

"Jay Pondy" <jp****@mindspring.com> wrote in message
news:bd**********@slb3.atl.mindspring.net...
Why not just using an enumerator and refer to the tables
cell collection?
Once you have a reference to the tablecell object you can
add to it's
controls collection.

"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
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 want to be able to
do something
like:

string day;
foreach ...
{
day = getShortDay(someDateTime);
[day + "Cell"].Controls.Add(new LiteralControl("put
some content in
this
cell.."));
}

Is there anyway to do this?

thank you - Trevor


--
Direct access to this group with http://web2news.com
http://web2news.com/?microsoft.publi...amework.aspnet

Nov 17 '05 #5
Sorry man, I misunderstood what you were trying to do.

Since you know what each row and cell in the table represent as far as
time is concerned go ahead and create the entire table and then loop
through your dataset as you stated. Based on the time stamp from your
data you should be able to determine which row and cell needs to be
referenced and you can access it as follows:

TimeTable.Rows(iRow).Cells(iCell).Controls.Add()

Trevor Hartman wrote:
ok i read up on enumeration and don't really understand
what you mean by
enumerating sun - sat. also, i don't want to loop through
my datacollection
98 times, which is how many cells there are. what I am doing now is
creating the table giving each cell a unique ID (date +
hour). if you want
to see the table, here it is:
http://www.futureshirts.com/calendar.../18/2003%2012:
00:00%20AM
wouldn't it be a better idea to just loop through the data
once after the
table is created, find the cell that matches the event by
date + hour, then
add the event to that cell? the only problem i'm having
is referencing the
cell. I could do a FindControl, but I don't really know
how to use the
results, since it is a control. I always get the "Object
reference not set
to an instance of an object". what do you think?

thanks - trevor

"Jay Pondy" <jp*****************@web2news.net> wrote in message
news:46*******@web2news.com...
Create the row and then enumerate Sun - Sat adding a cell
for each and
at the same time query the data source to see if you need to add a
literal control for that days cell contents.

Trevor Hartman wrote:
The table is dynamic, and I just want 7 individual table
cells, and create a
new instance every time I have a new row. how would I do
an enumerator in
this case??

its like this:
TableRow row = new TableRow(); etc.. Why not just using an enumerator and refer to the tables
cell collection?
Once you have a reference to the tablecell object you can
add to it's
controls collection.

"Trevor Hartman" <sy******@hotmail.com> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
> 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 want to be able to
> do something
like:
>
> string day;
> foreach ...
> {
> day = getShortDay(someDateTime);
> [day + "Cell"].Controls.Add(new LiteralControl("put
> some content in
this
> cell.."));
> }
>
> Is there anyway to do this?
>
> thank you - Trevor


--
Direct access to this group with http://web2news.com
http://web2news.com/?microsoft.publi...amework.aspnet
Nov 17 '05 #6
i finally got it working! thanks a lot for your help

-trevor

"Jay Pondy" <jp*****************@web2news.net> wrote in message
news:46*******@web2news.com...
Sorry man, I misunderstood what you were trying to do.

Since you know what each row and cell in the table represent as far as
time is concerned go ahead and create the entire table and then loop
through your dataset as you stated. Based on the time stamp from your
data you should be able to determine which row and cell needs to be
referenced and you can access it as follows:

TimeTable.Rows(iRow).Cells(iCell).Controls.Add()

Trevor Hartman wrote:
ok i read up on enumeration and don't really understand
what you mean by
enumerating sun - sat. also, i don't want to loop through
my datacollection
98 times, which is how many cells there are. what I am doing now is
creating the table giving each cell a unique ID (date +
hour). if you want
to see the table, here it is:

http://www.futureshirts.com/calendar.../18/2003%2012: 00:00%20AM

wouldn't it be a better idea to just loop through the data
once after the
table is created, find the cell that matches the event by
date + hour, then
add the event to that cell? the only problem i'm having
is referencing the
cell. I could do a FindControl, but I don't really know
how to use the
results, since it is a control. I always get the "Object
reference not set
to an instance of an object". what do you think?

thanks - trevor

"Jay Pondy" <jp*****************@web2news.net> wrote in message
news:46*******@web2news.com...
Create the row and then enumerate Sun - Sat adding a cell
for each and
at the same time query the data source to see if you need to add a
literal control for that days cell contents.

Trevor Hartman wrote:
The table is dynamic, and I just want 7 individual table
cells, and create a
new instance every time I have a new row. how would I do
an enumerator in
this case??

its like this:
TableRow row = new TableRow();

etc..
> Why not just using an enumerator and refer to the tables
> cell collection?
> Once you have a reference to the tablecell object you can
> add to it's
> controls collection.
>
> "Trevor Hartman" <sy******@hotmail.com> wrote in message
> news:OL**************@TK2MSFTNGP10.phx.gbl...
>> 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 want to be able to
>> do something
> like:
>>
>> string day;
>> foreach ...
>> {
>> day = getShortDay(someDateTime);
>> [day + "Cell"].Controls.Add(new LiteralControl("put
>> some content in
> this
>> cell.."));
>> }
>>
>> Is there anyway to do this?
>>
>> thank you - Trevor


--
Direct access to this group with http://web2news.com
http://web2news.com/?microsoft.publi...amework.aspnet

Nov 17 '05 #7

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

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
3
by: Michael | last post by:
Hi all : in vb.net I know use the follow code can implement dynamic call Dim asm As = .LoadFrom(<FileName>) Dim ty As Type = asm.GetType(<Object Name and class name>) Dim obj As Object =...
3
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
3
by: Tom | last post by:
Can I dynamic call vb.net object such like vb6 as sample dim A as object set a = createobject("myobject.test") a.open() now mypbject.test is create vb.net . How can I dynamic call without...
4
by: Tom | last post by:
Hi .Net Professional : In recent , I starting to learn about dynamic call .net object in vb.net. Before, some IT people teach me use the following method and its work !! Dim asm As =...
2
by: Luis Arvayo | last post by:
Hi, In c#, I need to dynamically create types at runtime that will consist of the following: - inherits from a given interface - will have a constructor with an int argument
12
by: andrew cooke | last post by:
Hi, This is my first attempt at new classes and dynamic python, so I am probably doing something very stupid... After reading the how-to for descriptors at...
0
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.