- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要在用户点击时从 dataGrid 中收取项目值,将其放入数据行 View 中以获取第一个值“IdEmployee”并分配给变量。
这是我的方法,问题是我的变量 dataRowView 是 Null!
我该如何解决这个问题?
private void _employeedataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataRowView dataRowView = _employeedataGrid.CurrentCell.Item as DataRowView;
var idEmployee = Convert.ToInt32(dataRowView.Row[0]);
.......
}
最佳答案
那是因为 _employeedataGrid.CurrentCell.Item
不能转换为 DataRowView
。为什么不尝试使用 CurrentRow
而不是 CurrentCell
?:
private void _employeedataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
DataRowView dataRowView = _employeedataGrid.CurrentRow.Item as DataRowView;
var idEmployee = Convert.ToInt32(dataRowView.Row[0]);
.......
}
关于c# - DataGrid 到 DataRowView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6391479/
我将combobox.datasource 设置为一个数据 View 项(以便它绑定(bind)到一个表),当我从combobox.selectedvalue 获得返回值时。返回错误,因为它的类型为“
在验证 ComboBox 时,我试图检查 ComboBox 中的值是否在数据绑定(bind)到所述 ComboBox 的值列表中。 数据源是 BindingSource,底层项目是 DataRowVi
我需要在用户点击时从 dataGrid 中收取项目值,将其放入数据行 View 中以获取第一个值“IdEmployee”并分配给变量。 这是我的方法,问题是我的变量 dataRowView 是 Nul
我在 winform 中有一个组合框,它通过调用 MySQL 中的存储过程来获取数据。 我的存储过程: CREATE PROCEDURE `GetCourses`() BEGIN SELECT cou
DataGrid.ItemSource 在代码后面设置为 dataview。列名和计数需要即时更改,因此对象列表不能很好地工作。 我的表格显示完全正常。这很好,但是我的 GridCellStyle 将
为了将DataTable连接到ComboBox或列出项目,我还需要添加其他内容吗? 当前,它将显示项目,但是它们都是System.Data.DataRowView,我不确定为什么。 ... ...
我有一个问题: SqlDataAdapter da = new SqlDataAdapter("SELECT dbo.User.name FROM dbo.User", con); DataTable
我想知道 DataView 和 DataRowView 的区别。我查阅了 MSDN,它说 DataRowView 只是 DataView 的自定义表示。 但是您也可以将 DataView 转换为 Da
我使用 linq to sql 来填充 gridview: var results = from r in db.MyForm1_hosps where r
protected void Page_Load(object sender, System.EventArgs e) { DataTable dt = GetDataTable("selec
场景是我想从所选行的 onMouseDoubleClick 事件中获取值。我将该行转换到 DataRowView,但该对象没有任何值(value)。在调试时,当我将光标悬停在 SelectedItem
除了循环、枚举 ICollection 以分别将它们转换为已知 ICollection 中的列的类型化列表之外,是否有任何可能的方法。我正在使用 .net Framework 2.0、C#2.0。预期
我们刚刚使用 Prism 启动了一个 WPF 项目。我们的问题是我们必须使用 System.Data.DataRowView 而不是 DataGrid 的类型化版本。我们正在使用这样的代码:
我有一个在主窗体打开时调用的方法 private void populateComboBoxes() { SqlCeDataAdapter breakfastAdapter = new Sql
我有一个组合框 cbAnalytes: cbAnalytes.DataSource = ConnectandReadList(qcvalues_query); ConnectandReadList 在
情况如下:我需要绑定(bind)一个 WPF FixedPage反对 DataRow .绑定(bind)不适用于 DataRows ;他们反对DataRowViews .我需要以最通用的方式执行此操作
我有一个ComboBox,它需要在下拉菜单中显示多个字段。但只想存储一个。现在,它可以显示多个字段。但是无论我选择什么,文本框中显示的值都是“System.Data.DataRowView”。有谁知道
我有这个代码 private void cmb_public_manag_SelectedIndexChanged(object sender, EventArgs e) { //DB_Ma
我正在尝试使用列中的值填充下拉列表。现在的问题是:我没有在下拉列表中获得实际值(国家代码,如印度 (+61))。相反,我在下拉列表中得到“System.Data.DataRowView”(多次)。
我的C#代码如下 private void offHwyManufacturer_SelectedValueChanged(object sender, EventArgs e) {
我是一名优秀的程序员,十分优秀!