[英]Databinding to a Hidden Aspxcombobox?
I have an aspxGridView control to list some records. 我有一个aspxGridView控件来列出一些记录。 I am using a combobox to fill some data, which is different from aspxgridview's .
我正在使用组合框填充一些数据,这与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();
}
}
I don't want to see "LnkHotelID" so I want it hidden. 我不想看到“ LnkHotelID”,所以我想隐藏它。 But when I hide this column, I can't use the function above.
但是,当我隐藏此列时,无法使用上面的函数。 Also I want to see "HotelName" column but not to update it.
另外,我想查看“ HotelName”列,但不想对其进行更新。
So I have two questions: 所以我有两个问题:
1) How can I access aspxcombobox at runtime? 1)如何在运行时访问aspxcombobox? 2) How can I show my HotelName but not edit them?
2)如何显示我的旅馆名称而不进行编辑?
Set the ASPxComboBox.ClientEnabled property to False: 将ASPxComboBox.ClientEnabled属性设置为False:
ASPxComboBox cmb = e.Editor as ASPxComboBox;
cmb.ClientEnabled = false;
When you hide column with visible=false it will not render that in HTML so you can't use above function. 当您隐藏带有visible = false的列时,它将不会以HTML呈现,因此您将无法使用上述功能。 So instead of visible false use style property with display: none
因此,与显示无关的可见的false使用样式属性:
<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. 现在您可以使用您的代码了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.