Click here to Skip to main content
11,495,493 members (64,539 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# VS2010
I'm trying to get a value from datagrid to combobox... How It can be done?? help,,,
Posted 20-Oct-12 0:17am
Sandeep Mewara at 20-Oct-12 5:40am
value from datagrid to combobox.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

foreach(gridviewrow gvr in Gridview1.Rows)

where lstGridColumn is a
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 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.
Sharath2790 at 21-Oct-12 1:09am
That doesn't work.....
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 265
3 Nakul Chaudhari 236
4 Sergey Alexandrovich Kryukov 230
0 Sergey Alexandrovich Kryukov 10,322
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,889
3 Maciej Los 3,422
4 Richard Deeming 2,560

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 21 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100