问题标签 [databound-controls]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
722 浏览

c# - 在 XML 加载后,DataGridView 无法将行添加为“控件是数据绑定的”

我通过加载到数据集从 XML 文件填充了 DataGridView。但是,在我加载数据后,我无法再在运行时插入行,因为我收到此错误:

“当控件绑定数据时,无法以编程方式将行添加到 datagridview 的行集合中”

我理解我认为的问题的概念。如果我的 XML 文件只包含 7 行并且是 DataGridView 的源,那么它绑定到 7 行并且不能添加更多行,但我希望用户能够动态更改它然后重新保存 XML。我可以知道如何重新保存,只是不知道如何“解锁”行问题。

非常感谢,汤姆

0 投票
2 回答
1204 浏览

c# - Accessing ComboBox.Items with Contains method for DataBound ComboBox

Summary:

I want to check the current ComboBox.text value against the list of items in a ComboBox that is assigned a DataSource at run time. If the text doesn't match an item in the list then it will select the first item in the list.


Here is what I originally tried:

However the above code does not work as expected because when inspecting the myComboBox.Items property at run time, it is actually a collection of System.Data.DataRowView objects. So basically it is comparing a String to DataRowView.ToString() which is always false unless the myComboBox.Text value is in fact "System.Data.DataRowView"...


So I thought

"Hey, lets make an extension method to search all the items of the DataViewRow and see if my requested value is in there!", but it's not going as planned...

I know that looks weird, but the code prettify won't work right if the <Extension()> part isn't separated. When I attempt to use my extension method in my main code, I get an error about my extension method not being a member of ComboBox.ObjectCollection which seems bogus to me because in the extension method I am specifically saying that the first parameter is a ComboBox.ObjectCollection.


Infamous "HOW TO BRAIN SURGERY WITH POTATO" request...

How can I determine that the text a user inputs into a databound ComboBox is in the list of items from the DataSource?

Side note: C# answers are fine so long as they have a VB.NET counterpart

0 投票
1 回答
991 浏览

c# - Gridview dataBound 从后面的代码中添加到列数据的超链接

使用网格视图从后面的代码绑定它:

我想将一个特定的列数据绑定到一个超链接中,所以当它点击它应该进行下载。

怎么做 ?

下面是我的代码:

0 投票
0 回答
83 浏览

asp.net - 访问嵌套 UpdatePanel 内的模型绑定项

访问嵌套 UpdatePanel 内的数据绑定项的正确方法是什么?我最近发现了模型绑定并喜欢它提供的强类型绑定,但我在整个页面中散布着 UpdatePanel,它似乎破坏了对Item对象的访问。如果整个数据绑定控件都在 UpdatePanel 内,我没有问题。这有效:

但如果 UpdatePanel 在绑定控件内,我将无法再访问Item. 这不起作用:

CS0103:当前上下文中不存在名称“项目”

我摸索到了一个笨重的解决方案,就是这个

但我非常希望这不是完成任务的最佳方式。

0 投票
2 回答
121 浏览

.net - 是否需要调度程序来更改 WPF .Net Core 3 或更高版本中的数据绑定属性?

许多示例(甚至来自 MS)使用调度程序来更新数据绑定属性,并且可以找到一堆不同的答案。是否存在“官方”声明?目前,我总是使用调度程序,并且只有在我确定这是一个官方功能并且它仍然适用于未来的 .Net 版本时,我才会更改它。