Method to utilize controls dynamically based on param passed in.....(this is possible, no?)
Posted on 2007-04-03
I am just curious- is it possible to have a method that takes an string as a parameter which passes in a number (1,2,3,4,etc) that is appended to the control values in order to have the same method work for a number of different controls (which are separated by panels, etc.)?
For instance (I know this won't work- but to get an idea of what I want to know):
((I would have several groups of ASP.NET controls with the same properties, but with names being differentiated by an appended number---->> ie. ddlDrop1, ddlDrop2, ddlDrop3, ddlDrop4......txtNew1, txtNew2, txtNew3, txtNew4, etc.))
protected void DynamicControlMethod(string inputNum)
ddlDrop + inputNum + .SelectedIndex = 0;
txtNew + inputNum + .Text = "something";
NOTE: I am not actually trying to do anything in the above- I just want to know how I can dynamically use the controls based on the 'inputNum' param. This must somehow be possible in C#, right?
Thanks a bunch in advance to all!!