473,508 Members | 3,343 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with C# code

Hi, I have a form which contains a table(Table1), within that table I have
label with an ID set to "1A".
Using something like:

if(Table1.FindControl("1B") != null)
{
labelID = "1C";
}
else if(Table1.FindControl("1A") != null)
{
labelID = "1B";
}

Label lblType = new Label();
lblType.ID = labelID;

TableRow tr = new TableRow();

TableCell tc = new TableCell();

tc.HorizontalAlign = HorizontalAlign.Center;

tr.Controls.Add(tc);

tc.Controls.Add(typeLabel);

Table11.Controls.Add(tr);

So whenever this code runs if it finds the latest Label for example "1B" it
will add a new tr and cell with an updated label "1C" or if it finds "1A" it
will update with new label "1B".

It does work with the initial label that is set in the .aspx file however
when run it again it will not find the new label to reupdate things.

Anyone have any suggestions?

thank you for any advice.
Mar 11 '08 #1
4 999
What do you mean by 'run it again'??
When Postbacking...
the whole Page will be new, so make sure to add your newly created control
as well otherwise it will not exists.


"Durango2008" <el********@yah00.c0mschreef in bericht
news:b8******************@newssvr13.news.prodigy.n et...
Hi, I have a form which contains a table(Table1), within that table I have
label with an ID set to "1A".
Using something like:

if(Table1.FindControl("1B") != null)
{
labelID = "1C";
}
else if(Table1.FindControl("1A") != null)
{
labelID = "1B";
}

Label lblType = new Label();
lblType.ID = labelID;

TableRow tr = new TableRow();

TableCell tc = new TableCell();

tc.HorizontalAlign = HorizontalAlign.Center;

tr.Controls.Add(tc);

tc.Controls.Add(typeLabel);

Table11.Controls.Add(tr);

So whenever this code runs if it finds the latest Label for example "1B"
it will add a new tr and cell with an updated label "1C" or if it finds
"1A" it will update with new label "1B".

It does work with the initial label that is set in the .aspx file however
when run it again it will not find the new label to reupdate things.

Anyone have any suggestions?

thank you for any advice.

Mar 11 '08 #2

"pipo" <no****@me.comwrote in message
news:On**************@TK2MSFTNGP06.phx.gbl...
What do you mean by 'run it again'??
When Postbacking...
the whole Page will be new, so make sure to add your newly created control
as well otherwise it will not exists.
I do add the new control with the lines:
TableRow tr = new TableRow();
TableCell tc = new TableCell();
tc.HorizontalAlign = HorizontalAlign.Center;
tr.Controls.Add(tc);
tc.Controls.Add(typeLabel);
Table11.Controls.Add(tr);

Did you mean something else?
Mar 12 '08 #3
What do you mean by 'run it again'??
"Durango2008" <el********@yah00.c0mschreef in bericht
news:zf*******************@newssvr21.news.prodigy. net...
>
"pipo" <no****@me.comwrote in message
news:On**************@TK2MSFTNGP06.phx.gbl...
>What do you mean by 'run it again'??
When Postbacking...
the whole Page will be new, so make sure to add your newly created
control as well otherwise it will not exists.

I do add the new control with the lines:
TableRow tr = new TableRow();
TableCell tc = new TableCell();
tc.HorizontalAlign = HorizontalAlign.Center;
tr.Controls.Add(tc);
tc.Controls.Add(typeLabel);
Table11.Controls.Add(tr);

Did you mean something else?


Mar 12 '08 #4

"pipo" <no****@me.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
What do you mean by 'run it again'??
I meant postback sorry for confusion.
Mar 12 '08 #5

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

Similar topics

15
3652
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit...
19
4066
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
11
2778
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field...
7
3287
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
48
3182
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
4
7385
by: Phil | last post by:
k, here is my issue.. I have BLOB data in SQL that needs to be grabbed and made into a TIF file and placed on the client (could be in temp internet dir). The reason we need it in TIF format is...
2
4420
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
15
4564
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
2734
by: Quas.co.ua | last post by:
Hello all. I need your help. I need C compler to make demo of some technologie. This C compiler I need to write program which after run will be located in one segment of memory and it...
20
4222
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
0
7129
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
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
7502
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...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.