如何添加DataGrid组合框列 [英] how to add a DataGrid Combo Box Column
问题描述
朋友,
从最近两天开始,我搜索了整个网络.但我没有得到任何有用的代码
关于一个DataGrid ComboBoxcolumn;我有一个带有4列的DataGrid,位置"
从",到"和调度状态".这些列绑定到MSAccess数据库,但是我希望将第4列作为ComboBoxColumn,以便它给出一些预先确定的值,例如combobox列中的"Dispatched","Received","ReturnedBack","waiting for delivery".
问候
iqbal
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.
regards
iqbal
推荐答案
我认为此链接将为您提供帮助.
http://bytes.com/topic/c-sharp/answers/900106-how-add-datagridcomboboxcolumn-datagrid-wpf [ ^ ]
I think this link will help you.
http://bytes.com/topic/c-sharp/answers/900106-how-add-datagridcomboboxcolumn-datagrid-wpf[^]
代替绑定字段",对组合框"列使用模板字段"
In stead of Bound Field use Template Field for the Combob box column
<asp:TemplateField HeaderText="Example">
<ItemTemplate>
<asp:DropDownList ID="ddExample" AutoPostBack="false" runat="server" />
</ItemTemplate>
</asp:TemplateField>
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;
这篇关于如何添加DataGrid组合框列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!