Solved

C#, update a textbox value...

Posted on 2014-07-20
4
387 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 34

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 34

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 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