Hey guys,

I am writing a web application in asp.net using c sharp. I have a web page that lets the user create a program. In this system a program is made up of many applications and an Application can belong to many programs hence a many to many relationship. I have made a application, program, and ProgramApplicationMapping tables.

On this webpage there is a few textboxes (ex Program_Id , Program_Name) follows by a checklist of application (set number) followed by a save button.

when i hit the save button i want to INSERT into the database ProgramApplicationMapping
which just has two col ( program_id, application_id).

i dont know how to script the sql statement since the number of entries is dependent on the users selections of apps.

Please help me with my problem. Thank you

I was thinking a do while loops that checks the checklist to see which ones are select, and if selected use a insert statement.

I'll share what I come up with

protected void btnSave_Click(object sender, EventArgs e)
       string Application_Id;
       string Program_Id = tbProgramId.Text;
       string Program_Name = tbProgramName.Text;
       int Contact_Id = int.Parse(ddlContacts.SelectedValue);
        foreach (ListItem item in applicationCheckList.Items)
            if (item.Selected)
                Application_Id = item.Value;
                InsertRelationship(Program_Id, Application_Id);

        InsertNewProgram(Program_Id, Program_Name, Contact_Id);
This question has already been answered. Start a new discussion instead.