0

我有一个 aspxGridView 控件来列出一些记录。我正在使用组合框来填充一些数据,这与 aspxgridview 的 .

protected void ASPxGridView1_CellEditorInitialize(object sender, ASPxGridViewEditorEventArgs e)
{         
        if (e.Column.FieldName == "LnkHotelID")
        {
            ASPxComboBox cmb = e.Editor as ASPxComboBox;
            cmb.DataSource = DsHtel;
            cmb.ValueField = "HotelID";
            cmb.ValueType = typeof(Int32);
            cmb.TextField = "HotelName";
            cmb.DataBindItems();
        }            
}

我不想看到“LnkHotelID”,所以我想隐藏它。但是当我隐藏此列时,我无法使用上面的功能。我还想查看“HotelName”列,但不想更新它。

所以我有两个问题:

1) 如何在运行时访问 aspxcombobox?2) 如何显示我的 HotelName 但不能编辑它们?

4

2 回答 2

0

Set the ASPxComboBox.ClientEnabled property to False:

ASPxComboBox cmb = e.Editor as ASPxComboBox;
cmb.ClientEnabled = false;
于 2013-07-18T19:48:27.207 回答
-1

When you hide column with visible=false it will not render that in HTML so you can't use above function. So instead of visible false use style property with display: none

<style>
   .hiddencolumn {display:none;}
</style>

<asp:GridView ID="GridViewHotel" runat="server" AutoGenerateColumns="false">
   <Columns>
    <asp:BoundField DataField="LnkHotelID" ItemStyle-CssClass="hidden"
        HeaderStyle-CssClass="hiddencolumn" />

</Columns>

</asp:GridView>

Now you can use your code.

于 2013-07-18T13:33:16.660 回答