Click here to Skip to main content
16,019,596 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a Parent page where I select Company name from a DropdownList. The company name is from the database. If I want to add a new company, I need a child page where I can add a new company to my database and get the new one in my DropdownList on the parent page.

How can I do this with ASP.net and C#? Please help or give me some links to examples.
Posted
Updated 31-Mar-13 1:53am
v2

1 solution

Create a form which gets the required info from the user - call it frmCompanyDetail for example.
Add an OK and an Cancel button, and in the designer set these properties:
Form:
StartPosition   CenterParent
ShowInTaskbar   False
AcceptButton    Your OK button
CancelButton    Your Cancel Button

OK Button:
DialogResult    OK

Cancel Button:
DialogResult    Cancel

And add the relevant Properties to your form to transfer the information.

In your Parent page, add this code:
C#
frmCompanyDetail nc = new frmCompanyDetail();
if (nc.ShowDialog() == DialogResult.OK)
   {
   // Use nc properties to retrieve the data and save to the DB
   ...
   }
If you do it like this, and implement the proiperties to transfer the info to and from the form controls, you can also use the same frmCompanyDetail to display and / or change company information later.
 
Share this answer
 

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