Solved

C#, update a textbox value...

Posted on 2014-07-20
4
386 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 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