** No Title can explain this one ** check it out :)

Okay, probably a major bad on my part but I thought it would be clever to create a look up table in sql server that holds the name of the form i.e lookForm1, description Example Form, display name Example

i.e. values from the table
"lookform1", "Form Test", "This is Test form 1"
"lookform2", "Form Test 2", "This is another Test"

this was fine for a couple of forms, bound to a dropdown list to pull the id(lookform1) and displayname(Form Test) so that when a user clicks this the form displays as follows

string _form = "look" + ddlLookupTables.SelectedValue.ToString();
                              case "lookCallStatus":
                                    lookCallStatus frm = new ERP.Forms.LookupForms.lookCallStatus();
                              case "lookCallType":
                                    lookCallType frm1 = new ERP.Forms.LookupForms.lookCallType();

Now the problem, the issue is that these lookup forms have grown dramatically and I'm tired of typing this shit over and over.

is there a way to pull that id (lookform1) and actually cast it as a form so that I can just do something like this.
string _form = "look" + ddlLookupTables.SelectedValue.ToString();

bugging the hell out of me and it's my fault hoping someone has a good idea.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed NasmanSoftware DeveloperCommented:

  You can do that using Activator.CreateInstance, here's a sample

                  string s = "Form2";                  

                  Form frm = (Form)Activator.CreateInstance("urAssemblyName","urAssemblyName.Form2").Unwrap();

joshcrosbyAuthor Commented:
I'm sorry can you elaborate a bit, not sure what you mean
Here is an example,

  string _form = ddlLookupTables.SelectedValue.ToString();

  Form frm = (Form)Activator.CreateInstance(Type.GetType(_form));

to determine how to refer to the forms in the database, use this code:



  If typeof(lookCallStatus).FullName returns "WindowsApplication1.lookCallStatus" then you would call Activator.CreateInstance(Type.GetType("WindowsApplication1.lookCallStatus")) to create an instance of the lookCallStatus form.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

joshcrosbyAuthor Commented:
Thanks a ton, that makes sense, damn that saved a ton of time, thanks again.
joshcrosbyAuthor Commented:
man you have no idea how much code and speed that changed, thanks a million.
Thanks for posting that feedback; it's very rewarding to know that helped!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.