Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to get a value from datagrid to combobox... How It can be done?? help,,,
Posted
Comments
Sandeep Mewara 20-Oct-12 5:40am    
value from datagrid to combobox.
Elaborate.

C#
foreach(gridviewrow gvr in Gridview1.Rows)
{
lstGridColumn.add(gvr.Cells[2].Text);
}


where lstGridColumn is a
C#
List<string></string>
type. You need to iterate through each rows in the grid and extract the value from each Column specified by Cells[2] in the code.

This is used for asp.net websites and webapplications, if it is a windows form application then you'll probably need the row index of the datagrid to work with.
Other than that we need more info on your problem...please elaborate.
 
Share this answer
 
Comments
Sharath2790 21-Oct-12 1:09am    
That doesn't work.....
It works some what like this...
Combobox1.text = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
Combobox2.text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
...
and so on...
 
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