Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8238753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:55:15+00:00 2026-06-07T19:55:15+00:00

In my Web Page, I have 2 List Boxes namely ListBox1,ListBox2.The user select the

  • 0

In my Web Page, I have 2 List Boxes namely ListBox1,ListBox2.The user select the list of items from ListBox1 and move it to ListBox2.I done up to this, but after i click the ‘SAVE’ button, it is not save the ListBox2 selected item in the SQL table and It is not throw any error!! how to store it ?

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
         lblPage1ID.Text=Server.UrlDecode(Request.QueryString["Parameter"].ToString());
         ListBoxWorksPackages();
        }
    }

    protected void ListBoxWorksPackages()
    {
        ListBox1.Items.Add("General Contractor");
        ListBox1.Items.Add("Architecture");
        ListBox1.Items.Add("Civil");
        ListBox1.Items.Add("Mechanical");
        ListBox1.Items.Add("Electrical");
    }

    protected void btnMoveRight1_Click(object sender, EventArgs e)
    {
        for (int i = ListBox1.Items.Count - 1; i >= 0; i--)
        {
            if (ListBox1.Items[i].Selected == true)
            {
                ListBox2.Items.Add(ListBox1.Items[i]);
                ListItem li = ListBox1.Items[i];
                ListBox1.Items.Remove(li);
            }
        }
    }

    protected void btnMoveLeft1_Click(object sender, EventArgs e)
    {
        for (int i = ListBox2.Items.Count - 1; i >= 0; i--)
        {
            if (ListBox2.Items[i].Selected == true)
            {
                ListBox1.Items.Add(ListBox2.Items[i]);
                ListItem li = ListBox2.Items[i];
                ListBox2.Items.Remove(li);
            }
        }
    }

    protected void BtnSave1_Click(object sender, EventArgs e)
    {
        SqlConnection SqlCon = new SqlConnection(GetConnectionString());

        string Packagevalues = string.Empty;
        foreach (ListItem item in ListBox2.Items)
        {
            if (item.Selected == true)
            {
               Packagevalues += "," + item.Text; 
            }
        }

        string query = "INSERT INTO Contractor_Info2 (Vendor_ID,WorksPackage) VALUES"
                           + "(@Vendor_ID,@WorksPackage )";

        try
        {
            SqlCommand cmd = new SqlCommand(query, SqlCon);
            cmd.CommandType = CommandType.Text;

            SqlCon.Open();

            cmd.Parameters.AddWithValue("@Vendor_ID", lblPage1ID.Text);
            cmd.Parameters.AddWithValue("@WorksPackage", Packagevalues);
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
        finally
        {
            SqlCon.Close();
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:55:19+00:00Added an answer on June 7, 2026 at 7:55 pm

    you need to call cmd.ExecuteNonQuery() after you’ve added the parameters to your sql procedure. this is what will actually run your sql statement.

        try
        {
            SqlCommand cmd = new SqlCommand(query, SqlCon);
            cmd.CommandType = CommandType.Text;
    
            SqlCon.Open();
    
            cmd.Parameters.AddWithValue("@Vendor_ID", lblPage1ID.Text);
            cmd.Parameters.AddWithValue("@WorksPackage", Packagevalues);
            // add this
            cmd.ExecuteNonQuery();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of items on my web page that the user can
I have a web page with many select boxes, which should each contain the
On a web page I have a quite large list of items (say, product
On my web page, I have a list of images. Currently, when the user
So I have a list of avi files on a web page (For my
I have a web page that displays a list of documents stored on the
I have a web page with a GridView. The GridView contains a list of
Hi I have a page in my java/jsp based web application which shows list
I have an asp.net page with several list boxes. I would like to include
I have this scenario. I need to show 3 list boxes on a ASP.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.