You must Sign In to post a response.
  • Category: ASP.NET

    Through multi select listbox store in database

    this is my project table
    create table tbl_project_master
    (
    Project_id int primary key,
    Project_code varchar(20) not null unique,
    Project_name varchar(50),
    Project_Description varchar(max),
    Start_of_Date datetime,
    End_of_Date datetime
    )

    this is my task table
    create table tbl_subtask_master
    (
    Task_Id int primary key,
    Task_Name varchar(50),
    Task_Description varchar(max)
    )

    this is child table
    create table tbl_project_subtask
    (
    Project_id int FOREIGN KEY REFERENCES tbl_project_master(Project_id),
    Subtask_Id int FOREIGN KEY REFERENCES tbl_subtask_master(Task_Id)
    )

    project id is in one drop down list
    task name in list box
    when am selecting project id and multiple task name values that will insert into child table that is tbl_project_subtask in database
  • #767351
    Hi mounika,

    Ok, your requirement is good, what you want now from our end?

    What you have tried so far, have you Google the same?

    did you get the selected items from listbox?

    If not, First get the selected listbox items and insert one by one into database.

    Ex:

    foreach (ListItem item in ListBox1.Items)
    {
    if (item.Selected)
    {
    // your insert statement here;
    }
    }


    If you need more help then go through the below link this might be helpful to you.

    aspsnippets.com/Articles/ASP.Net-ListBox-Save-Multiple-Selected-Items-in-the-Database.aspx

    Before asking any question first you just check with Google....

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments