所以我有一个Dev Express gridview,它被绑定到后面的cod中的数据源。这个数据源只是一个常规的ORM对象,它工作正常。当我在记录上点击编辑时,我试图将其中一列变成组合框。到目前为止,我已经能够使用以下代码完成此任务:
<dx:GridViewDataComboBoxColumn Caption="Invoice/Return#"
FieldName="InvoiceNumber" ToolTip="Invoice/Return#"
VisibleIndex="4" Settings-AllowSort="False" Name="cmbOtherCostsInvoice">
<PropertiesComboBox ClientInstanceName="cmbOtherCostsInvoice">
</PropertiesComboBox>
<Settings AllowSort="False"></Settings>
</dx:GridViewDataComboBoxColumn>
我拦截行编辑事件并像这样绑定组合框:
protected void gridViewOtherCost_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
{
var allInvoices = GetCollection<PurchaseOrderInvoice>("PURCHASE_ORDER_KEY = " + purchaseOrder.Key);
foreach (var item in allInvoices)
{
(gridViewOtherCost.Columns[4] as GridViewDataComboBoxColumn).PropertiesComboBox.Items.Add(item.InvoiceNumber, item.InvoiceKey);
}
}
所以这可行,但我想让组合框成为多列。我在整个应用程序中都有一些其他的多列,但没有一个嵌套在gridview中,所以我不知道该怎么做。以下是独立多列组合框的示例。
<dx:ASPxComboBox ID="cmbAssetPart" runat="server" CssClass="requiredfield" Width="100px
ValueField="AssetKEY" TextField="AssetID" TextFormatString="{0}">
<Columns>
<dx:ListBoxColumn FieldName="AssetID" Name="AssetID" />
<dx:ListBoxColumn FieldName="EntityName" Name="Entity" />
</Columns>
知道如何才能让它发挥作用吗?
答案 0 :(得分:2)
在PropertiesComboBox标记之间定义Columns集合:
<dx:GridViewDataComboBoxColumn ....>
<PropertiesComboBox ClientInstanceName="cmbOtherCostsInvoice">
<Columns>
<dx:ListBoxColumn FieldName="AssetID" Name="AssetID" />
<dx:ListBoxColumn FieldName="EntityName" Name="Entity" />
</Columns>
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>