Click here to Skip to main content
15,921,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Point_Of_Sale.CustomerInfoDataSet.ItemsDataTable items = new CustomerInfoDataSet.ItemsDataTable();
            itemsTableAdapter.Fill(items);

            //dataGridView1.DataSource = items;
            comboBox1.DisplayMember = "ItemName";
            comboBox1.DataSource = items;
Posted
Updated 16-Jan-12 21:01pm
v2
Comments
Anuja Pawar Indore 17-Jan-12 3:02am    
Removed extra pre tag

ok man i want to try to help you, as i understand you have combobox and datagridview and you need to bing the selected items from combo to grid....it is easy man:
first you must ckeck the selected or checked items of the combo


XML
List<string> lstString = new List<string>();
        foreach (ListItem lItem in combo.Items)
        {
            if (lItem.Selected)
            {
                lstString.Add(lItem.Value);
            }
        }

in this way you are adding the IDs of the selected items in combo into a list of strings(list of IDs), then you have to get the objects item of these IDs:

List<items> lst = new List<items>();//insted of Items put your class
        Items item = new Items();
        foreach(string s in lstString)
        {
            item = lstItem.FirstOrDefault(p => p.ID == s);
            lst.Add(item);
        }</items></items>

now you must bind the grid , to give it datasource which is the list of items
grid.DataSource = lst;

Note: when you bind you combobox you have to put items in
session[""] in order to keep data alive becuese we need to search via it

best regards
 
Share this answer
 
ok man i want to try to help you, as i understand you have combobox and datagridview and you need to bing the selected items from combo to grid....it is easy man:
first you must ckeck the selected or checked items of the combo


XML
List<string> lstString = new List<string>();
        foreach (ListItem lItem in combo.Items)
        {
            if (lItem.Selected)
            {
                lstString.Add(lItem.Value);
            }
        }

in this way you are adding the IDs of the selected items in combo into a list of strings(list of IDs), then you have to get the objects item of these IDs:

List<items> lst = new List<items>();//instead of Items put your class
        Items item = new Items();
        foreach(string s in lstString)
        {
            item = lstItem.FirstOrDefault(p => p.ID == s);
            lst.Add(item);
        }</items></items>

now you must bind the grid , to give it datasource which is the list of items
C#
grid.DataSource = lst;


Note: when you bind you combobox you have to put items in
session[""] in order to keep data alive becuese we need to search via it

best regards
 
Share this answer
 

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