为ASPxComboBox 控件动静态绑定下拉项的方法
2009-03-18 17:54
651 查看
1定义提供数据源的方法:protected IEnumerable GetParentRoleDataSource(object categoryId)
{
IEnumerable results = from r2 in eDataContext.Role
where r2.IsDeleted == false
select new { ParentRoleID = r2.RoleID, ParentRoleName = r2.RoleName };
return results;
}
2. 页面绑定数据源和键值,并且用value关联好
<dxe:ASPxComboBox ID="parentRoleComb" runat="server" Value='<%# Eval("ParentRoleID")%>' ValueField="ParentRoleID" TextField="ParentRoleName"
DataSource='<%# GetParentRoleDataSource(Eval("ParentRoleID")) %>' ValueType="System.Int32">
</dxe:ASPxComboBox>
3.在ASPxGridView1_HtmlEditFormCreated事件中为下拉框绑定顶级角色的值: ASPxComboBox currentBox = ((ASPxGridView)sender).FindEditFormTemplateControl("parentRoleComb") as ASPxComboBox;
//给DropDownList手动添加显示值(包括对应的后台值)
ListEditItem item = new ListEditItem("没有父角色", "0");
currentBox.Items.Insert(0, item); //把值添加到指定的索引位置
{
IEnumerable results = from r2 in eDataContext.Role
where r2.IsDeleted == false
select new { ParentRoleID = r2.RoleID, ParentRoleName = r2.RoleName };
return results;
}
2. 页面绑定数据源和键值,并且用value关联好
<dxe:ASPxComboBox ID="parentRoleComb" runat="server" Value='<%# Eval("ParentRoleID")%>' ValueField="ParentRoleID" TextField="ParentRoleName"
DataSource='<%# GetParentRoleDataSource(Eval("ParentRoleID")) %>' ValueType="System.Int32">
</dxe:ASPxComboBox>
3.在ASPxGridView1_HtmlEditFormCreated事件中为下拉框绑定顶级角色的值: ASPxComboBox currentBox = ((ASPxGridView)sender).FindEditFormTemplateControl("parentRoleComb") as ASPxComboBox;
//给DropDownList手动添加显示值(包括对应的后台值)
ListEditItem item = new ListEditItem("没有父角色", "0");
currentBox.Items.Insert(0, item); //把值添加到指定的索引位置
相关文章推荐
- 将DataTable绑定到wpf的ComboBox控件方法
- WinForm控件复杂数据绑定常用数据源(对Combobox,DataGridView等控件DataSource赋值的多种方法)
- 将DataTable绑定到wpf的ComboBox控件方法
- WinForm中comboBox控件数据绑定实现方法
- 在.aspx.cs(后台)中对aspx控件绑定前台Javascript函数的几种方法
- WinForm控件复杂数据绑定常用数据源(对Combobox,DataGridView等控件DataSource赋值的多种方法)
- WinForm控件复杂数据绑定常用数据源(如:Dictionary)(对Combobox,DataGridView等控件DataSource赋值的多种方法)
- WinForm控件复杂数据绑定常用数据源(如:Dictionary)(对Combobox,DataGridView等控件DataSource赋值的多种方法)
- 静态页面HTML绑定动态数据.aspx,用document.write的方法!
- 用户控件.ascx与网页.aspx交互的几种方法
- wpf ComboBox 控件利用DataSet数据绑定
- Eval()、XPath() 和 Bind() 这类数据绑定方法只能在数据绑定控件的上下文中使用。
- Android 控件绑定事件的几种方法
- asp.net中将数据库绑定到DataList控件的实现方法与实例代码
- Dev控件系列之ASPXGridview控件自主绑定数据
- winform技巧—combobox控件数据绑定
- winform有一个combobox和一个textbox控件,如何进行动态绑定,使得combobox中的数据改变时,textbox中的数据也随之改变?
- 求动态绑定控件ID的值的方法!着急!
- ComboBox 经验总结[动态绑定数据之后,静态添加一条数据]
- 绑定DDL控件方法