Click here to Skip to main content
15,918,330 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI

I want to convert this

Hashtable["labelA1"]=labelA1.Text;

to Below
string k;
k="labelA1";

Hashtable["labelA101"]=string to label("k");
Posted

1 solution

How exactly you would do that would depend on the environment your code is running in: The first bit is easy:
C#
string k = "labelA1";
Hashtable[k] = ...

It's the second bit that changes.
For web based, then this might do it:
C#
string = "labelA1";
Control c = FindControl(k);
Label l = c as Label;
if (l != null)
   {
   Hashtable[k]=l.Text;
   }
If it isn't, then we need to know what you are running in...
 
Share this answer
 
Comments
sarath para 5-Jun-14 7:10am    
Hi Griff

Am doing win form C#
Thanks for info
I need to do same thing for a bUtton

Iam having below error

Error 1 Cannot convert type 'method group' to 'System.Windows.Forms.Button' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion C:\Users\sb.para\Documents\Visual Studio 2008\Projects\HDMT_UI7\WindowsFormsApplication7\Data.cs 86 46

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900