Dynamically creating controls based on variable
<p>First off I'm actually a DBA and not a web developer so... what I write will probably look ugly. I am building a website (they asked me if I'd try /shrug) and I have 168 checkboxes that have the same action when checked. But these actions, though the same, are performed on different controls (related to the checkbox). Instead of having a switch statement with 168 conditions can I do something like the following?</p>

<pre><code>CheckBox myCB = (CheckBox)(sender);

String mySTR = myCB.ID.ToString();
String myGVstr = “gv” + mySTR.Substring(mySTR.IndexOf(‘cb’) + 1);
String myBTNstr = “btn” + mySTR.Substring(mySTR.IndexOf(‘cb’) + 1);

GridView myGV = myGVstr;
Button myBTN = myBTNstr;

// Do what I need to do with these controls
...
</code></pre>
