Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Friends,

I am having a 2 list box control.It is having multipleselectoption to true.The value of the listboxcontrol selected item is inserted into sql table in the "Primary Impacted area"column like "ex1,ex2,ex3".In the below code it is working for first listbox control.But in "secondary Impacted area" it is not working.Please help me.

  cmd.Parameters.AddWithValue("@primaryimpactedarea",lstPrimaryImpactedArea.SelectedItem.Text);
       foreach (ListItem item in lstPrimaryImpactedArea.Items)
       {

           if (item.Selected)
           {

               try
               {
                   lblMessage.Text = lblMessage.Text + item.Text + ",";
                   cmd.Parameters[
"@primaryimpactedarea"].Value = lblMessage.Text;
               }
               catch (Exception ex)
               {
               }
           }
       }



 cmd.Parameters.AddWithValue("@secondaryimpactedarea", lstSecondaryImpactedArea.SelectedItem.Text);
       foreach (ListItem item in lstSecondaryImpactedArea.Items)
       {

           if (item.Selected)
           {

               try
               {
                   lblMessage.Text =  item.Text + ",";
                   cmd.Parameters[
"@secondaryimpactedarea"].Value = lblMessage.Text;
               }
               catch (Exception ex)
               {
               }
           }
       }
Posted
Comments
Sergey Alexandrovich Kryukov 26-Nov-13 0:55am    
What is "ListBox", exactly? Which one? Full type name, please.
—SA
Member 10234093 26-Nov-13 0:57am    
listbox is a toolbox control
Sergey Alexandrovich Kryukov 26-Nov-13 0:59am    
Type name, please!
If you don't understand what is "type name", you should stop programming more advanced things including and UI and get back to basics.
—SA
Member 10234093 26-Nov-13 1:01am    
Listbox1 name--->Primary Impacted Area

Listbox2 name--->Secondary Impacted Area
Sergey Alexandrovich Kryukov 26-Nov-13 1:05am    
That's enough. You really cannot give us a full name of "TextBox", the one you are using?
If you write
TextBox myTextBox = new TextBox();
string typeName = myTextBox.GetType().FullName;

what value will be in typeName?

—SA

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