Solved

C#, update a textbox value...

Posted on 2014-07-20
4
379 Views
Last Modified: 2014-07-28
ReadFromDict <-- is an object
ReadFromDict.YYYYConrol  <--  gives string like "yYYY_Left" and ReadFromDict.YYYY   <-- gives string value like 2014
I am trying to put 2014 into the text box with the name as string "yYYY_Left".  The following code doesn't work:
TextBox myTextBox =new TextBox(ReadFromDict.YYYYConrol);
myTextBox.Text = ReadFromDict.YYYY.ToString();

Open in new window

Question: Could you please show me how this is done?

Thank you.
0
Comment
Question by:Mike Eghtebas
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
Ivo Stoykov earned 400 total points
ID: 40208277
hi

There is no TextBox constructor taking parameters and you probably should add the new control somewhere...

try something like
TextBox myTextBox =new TextBox();
myTextBox.ID = ReadFromDict.YYYYConrol;
myTextBox.Text = ReadFromDict.YYYY.ToString();
form1.Controls.Add(myTextBox);

Open in new window

HTH

Ivo Stoykov
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40208290
Hi Ivo,

re:> There is no TextBox constructor taking parameters and ....
That understood. Thanks for the info on that.

re:> you probably should add the new control somewhere...
Does this mean I cannot use the existing text boxes? It seems you are creating brand new text boxes. If so, is there any way to cycle through the text boxes on the form and when their name matches ReadFromDict.YYYYConrol then enter the string value in ReadFromDict.YYYY.ToString() in to that text box?

Thanks,

Mike
0
 
LVL 16

Assisted Solution

by:Kamal Khaleefa
Kamal Khaleefa earned 100 total points
ID: 40208333
if you have the text box in your aspx page

then just set the text

yourTextBoxID.Text= ReadFromDict.YYYY.ToString()
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40208338
re:> then just set the text
As stated in the original post, that is not an acceptable option. That requires many lines of code and difficult to maintain.

Mike
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now