Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: WPF C#4.0 DataGrid
hi friends,
since last two days I searched the entire web. but I did not get any useful code
regarding a DataGrid ComboBoxcolumn;I have a DataGrid with 4 columns,"Location"
"From" "To"and "DispatchStatus". these columns are binded to a MSAccess DataBase .but the 4 th column I want as a ComboBoxColumn,so that it gives some pre decided value such as "Dispatched" "Received" "ReturnedBack" "waiting for Delivery" in the comboboxcolumn.
Posted 12-Feb-12 9:49am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

In stead of Bound Field use Template Field for the Combob box column

<asp:TemplateField HeaderText="Example">
                                                                <asp:DropDownList ID="ddExample"  AutoPostBack="false" runat="server" />

and in .cs file write the function to get values need to listed on Drop Down 
and on gdv_RowDatabound event bind it with gridview
like this
<pre lang="c#"><pre>DropDownList ddexample = (DropDownList)e.Row.FindControl("ddExample");
                    ddexample .DataSource = options;
          ddexample .DataTextField =options.Columns["Examples"].ToString();
          ddexample .DataValueField = options.Columns["Examples"].ToString();
                    ddexample .DataBind();
                    TableCell gridview= e.Row.Cells[10];
                    ddexample .SelectedValue = ddexample .Text;
MohammadIqbal at 13-Feb-12 7:06am
in case of WPF DataGrid

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 719
1 CHill60 315
2 Sergey Alexandrovich Kryukov 240
3 TheRealSteveJudge 190
4 Peter Leow 160
0 Sergey Alexandrovich Kryukov 9,193
1 OriginalGriff 6,786
2 Peter Leow 4,332
3 Zoltán Zörgő 3,809
4 Richard MacCutchan 2,672

Advertise | Privacy | Mobile
Web04 | 2.8.150128.1 | Last Updated 18 Apr 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