将 GridViewComboBoxColumn 绑定到数据源
我已经知道如何指定数据源,但这样做之后它还没有填充,所以我想你需要某种 bind() 命令来填充编辑表单中的组合框列 下面是我如何将数据源绑定到组合框列(是的,我确信 ds 中有数据行)
(ASPxGridView4.Columns["Naam"] as GridViewDataComboBoxColumn).PropertiesComboBox.DataSource = ds as DataSet;
那么谁能告诉我现在如何在编辑模式下填充组合框列?
编辑
protected void ASPxGridView4_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
{
if (dt.Rows.Count < 1)
{
ds = Session["ds"] as DataSet;
}
GridViewDataComboBoxColumn column = (ASPxGridView4.Columns["Naam"] as GridViewDataComboBoxColumn);
column.PropertiesComboBox.DataSource = ds.Tables[0];
column.PropertiesComboBox.ValueField = "Naam";
column.PropertiesComboBox.ValueType = typeof(string);
column.PropertiesComboBox.TextField = "Naam";
}
I already know how to specify the datasource but afther doing that it is not populated yet so i was thinking you need some kind of bind() command to populate the comboboxcolumn in the edit form
This below is how i bind the datasource to the comboboxcolumn (and yes i am sure that ds has data rows in it)
(ASPxGridView4.Columns["Naam"] as GridViewDataComboBoxColumn).PropertiesComboBox.DataSource = ds as DataSet;
So could anyone tell me how i can now populate the comboboxcolumn in edit mode?
Edit
protected void ASPxGridView4_InitNewRow(object sender, DevExpress.Web.Data.ASPxDataInitNewRowEventArgs e)
{
if (dt.Rows.Count < 1)
{
ds = Session["ds"] as DataSet;
}
GridViewDataComboBoxColumn column = (ASPxGridView4.Columns["Naam"] as GridViewDataComboBoxColumn);
column.PropertiesComboBox.DataSource = ds.Tables[0];
column.PropertiesComboBox.ValueField = "Naam";
column.PropertiesComboBox.ValueType = typeof(string);
column.PropertiesComboBox.TextField = "Naam";
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是应该有效的代码:
另外,请参阅 GridViewDataComboBoxColumn 类 主题。
更新 您的代码应在 CellEditorInitialize 事件中实现,如下所示:
Here is the code which should work:
Also, please refer to the GridViewDataComboBoxColumn Class topic.
UPDATE Your code should be implemented in the CellEditorInitialize event as shown below: