【原创】有关Silverlight中“DataGrid中级联动态绑定父/子ComboBox ”的示例。
尝试了很多种方案,由于Datagrid动态生成的每行父子comboBox的Name的不确定性,给父ComboBox绑定事件中获取 子ComboBox很难根据Name获取到。
花了不少时间和公司同事商讨,最终方案如下:
注:父子combobox分别代表: 主行业/子行业
private void CurrentRowIndusrtylist_SelectionChanged(object sender, SelectionChangedEventArgs e){ComboBox combobox = sender as ComboBox;//获取另一个conbox控件CurrentRowIndusrtylist = (sender as ComboBox);if (CurrentRowIndusrtylist != null){ DataGridCell dg = (DataGridCell)(CurrentRowIndusrtylist.Parent);//关键用法if (DataGridRow.GetRowContainingElement(dg) != null){ CurrentRowIndusrtySublist = this.dataGrid9.Columns[3].GetCellContent(DataGridRow.GetRowContainingElement(dg)) as ComboBox;//关键用法if (CurrentRowIndusrtySublist != null) BindSubIndusrtyCodes();//动态去绑定子combobox}}}private void BindSubIndusrtyCodes(){if (CurrentRowIndusrtylist.SelectedItem != null){var unitIndusrtyItem = CurrentRowIndusrtylist.SelectedItem as System_IndustryCodes;_db.Load(_db.GetIndustryCodesQuery(), op =>{CurrentRowIndusrtySublist.Items.Clear();CurrentRowIndusrtySublist.Items.Add(new System_IndustryCodes { ID = -1, IndustryCodes = "--请选择子行业--" });IEnumerable<System_IndustryCodes> tempsubList = op.Entities.Where(q => q.ParentCodeID == unitIndusrtyItem.ID);foreach (var temp in tempsubList){if (temp == null)return;CurrentRowIndusrtySublist.Items.Add(new System_IndustryCodes { ID = temp.ID, IndustryCodes = temp.IndustryCodes });}CurrentRowIndusrtySublist.DisplayMemberPath = "IndustryCodes";CurrentRowIndusrtySublist.SelectedValuePath = "ID";CurrentRowIndusrtySublist.UpdateLayout();if (CurrentRowIndusrtySublist.Items.Count == 1)CurrentRowIndusrtySublist.SelectedIndex = 0;elseCurrentRowIndusrtySublist.SelectedIndex = 1;//if (_OldSubindustryId != 0)//CurrentRowIndusrtySublist.SelectedItem = (from q in CurrentRowIndusrtySublist.Items where (q as System_IndustryCodes).ID == _OldSubindustryId select q).FirstOrDefault();//默认选择项-子行业}, null);}}
最终效果:
转载于:https://www.cnblogs.com/x-poior/p/4897353.html
【原创】有关Silverlight中“DataGrid中级联动态绑定父/子ComboBox ”的示例。相关推荐
- JQ 导出easyui中datagrid中的数据到excel表格中
///前端 <a href="#" class="easyui-linkbutton" id="id_exportTableToEcxel&qu ...
- flex中datagrid中的过滤功能
代码来自http://try.flex.org/index.cfm <?xml version="1.0" encoding="utf-8"?> & ...
- easyu中datagrid 中load 与reload区别
$('#roleTable').datagrid('reload'); 这种加载会跳到第一页 $('#roleTable').datagrid('load');这种加载会停留在当前页
- easyUI中datagrid中getSelected和getSelections的用法
注:https://www.cnblogs.com/FTDtt/p/4754660.html
- 【分享】WebForm中DataGrid的20篇经典文章
1.DataGrid动态模板列更新数据并且分页的例子 http://www.cnblogs.com/lovecherry/archive/2005/03/26/126102.html 2.DataGr ...
- 【分享】WebForm中DataGrid的经典文章 及一些网址收藏
[分享]WebForm中DataGrid的20篇经典文章 自认为以下文章比较经典,希望对初学者有用^_^ 1.DataGrid动态模板列更新数据并且分页的例子 http://www.cnblogs.c ...
- 技巧:Silverlight应用程序中如何获取ASP.NET页面参数
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://terrylee.blog.51cto.com/342737/87093 ...
- 服务器lIS绑定网站,DataList 中动态绑定服务器子控件的代码
DataList 中动态绑定服务器子控件的代码 更新时间:2007年09月10日 21:54:04 作者: 1.首先绑定dbList (一个DataList控件名称) 2.设置绑定子控件需要的关键 ...
- 在DataGrid中显示图片
兼谈 DadaGrid 模板列的创建 DadaGrid 是 ASP.NET 编程中一个很重要的控件,其优良的可定制功能为提高它的表现力提供了极大的方便.除了与数据源直接绑定以外,我们还可以通过列绑定模 ...
最新文章
- PowerShell-5.网络请求
- prism项目搭建 wpf_Prism完成的一个WPF项目
- leetcode 402. Remove K Digits | 402. 移掉 K 位数字(单调栈)
- 如何制作自己的静态库
- 151. 翻转字符串里的单词(思路+详解)
- sqlserver无法连接到服务器的常见原因和解决办法
- wireshark linux远程,如何在SSH连接Linux的环境下使用wireshark抓包云边端架构?
- 盘点下 NSX-v 中“不合理”的命名
- Linq之Lambda进阶
- 大学生个人网页设计 HTML个人网页制作 web个人网站模板 简单静态HTML个人网页作品
- 网上管家婆软件,最新在线进销存软件。
- 【Python计量】自相关性(序列相关性)的检验
- Skype 8.34 Windows7-64bit Ubuntu 16.04安装试验
- 2021年华为总监知乎1867赞的Java面试题全集解析助我修行,不吃透感觉都对不起他(上)
- 安卓机顶盒刷linux系统下载,安卓机顶盒刷机 最简单的刷机教程【图文教程】
- 是德科技34901A支持的量程
- python中使用大写字母来分割字符串
- 已经围上为何不算目_有答案的小学语文教师教材过关考试模拟试卷1
- NOJ 1116 哈罗哈的大披萨 【淡蓝】 状态压缩DP
- LaTeX 中使用三级标题
热门文章
- c#怎么读htm文件_c#怎么读写文件和获取文件的扩展名
- python海贼王logo_Python实现的下载op海贼王网的图片
- java 定义一个未知长度数组
- 019_MySQL正则表达式
- 090_块元素行内元素行内块元素空元素
- 图卷积网络进行骨骼识别代码_【骨骼行为识别】2s-AGCN论文理解
- 12C OCP 1Z0-063 题库(8月以前)
- 第九章 Oracle结构及数据库表与开发语言的对应关系、Oracle数据类型char与varchar
- pil获得图片_OpenCV读取图片与PIL读取图片的差别
- nacative mysql_MySQL索引优化