Solved

C#, update a textbox value...

Posted on 2014-07-20
4
385 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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