Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
SQL
public void Bind()
        {

            _initializing = true;

            dataComboBox.DataBindings.Clear();
            dataComboBox.SelectedIndex = -1;
            dataComboBox.Text = "";

        // I want to insert an empty item in the datasource

            dataComboBox.DataSource = Model.ContAccesslist.Insert(0,); <-- What would be second parameter i need to insert...
            dataComboBox.DisplayMember = "DataName";
            dataComboBox.ValueMember = "id";
          
        }


BLL:
public List<ContViewModel> ContAccesslist { get; set; }

DAL:
public class ContViewModel
    {
        public int Id { get; set; }
        public string DataName { get; set; }
        public string DataType { get; set; }


    }



Thanks in advance!!!
Posted
Updated 19-Jun-14 5:51am
v3
Comments
Sergey Alexandrovich Kryukov 19-Jun-14 12:36pm    
What do you want if you did not show even the declaration of Model; so we don't know what is ContAccesslist? The post does not seem to make sense at the moment. Would you use Improve question?
—SA
apr1234 19-Jun-14 12:57pm    
Yup contAccessList is present in another layer BLL of type list...

1 solution

C#
var items = Model.ContAccesslist;
items.Insert(0,new ContViewModel(){DataName ="", DataType="", Id =-1 } );
dataComboBox.DataSource = items;  
dataComboBox.DisplayMember = "DataName";
dataComboBox.ValueMember = "id";
 
Share this answer
 
v2
Comments
apr1234 19-Jun-14 12:49pm    
Thank you very much.. It is perfectly correct solution!!!!
I accepted it as solution.

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