DataBound ListBox - 想要添加项目和更新DB [英] DataBound ListBox - want to add item and update DB
问题描述
Hi Team,
对以下内容感兴趣。在谷歌这之后接缝到许多不同的答案。
(可能我也不理解数据绑定的概念,这个概念相当新)
我有一个字符串列表来自数据库,我将数据绑定到列表框。
Hi Team,
Was interested on the following. Seams to many different answers after Google this.
(It could be I dont understand the concept of Databinding either, fairly new to this concept)
I have a list of Strings which came from a Database that I am databinding to a list Box.
mXXBindiongs = new DataBindingSource
mXXDataSet = DB.GetDataSet
mXXBindiongs.DataSource = mXXDataSet
mXXBindiongs.DataMember = mXXDataSet.Tables(0).TableName
ListBox.DataSource = mXXBindiongs
ListBox.DisplayMember = "HeadingX"
在Winform I中使用某些操作想要捕获结果字符串将其添加到列表中,以便更新数据库以及更新WinForm中的列表框。
我有点困惑,因为正确更新此更新和所有更新的方法发生。
如果有人可以提供帮助那就太棒了。
非常感谢提前。
Stephan
With certain operations with-in the Winform I want to capture the resulting string add it to the list so it updates the Database as well as update the List Box in WinForm.
I am a little confused as the correct way to update this and all updates to occur.
If someone could help that would be wonderfull.
Many Thanks in advance.
Stephan
推荐答案
您必须使用新项更新数据库,然后重新查询数据库以检索更新的表。 br />
BTW,你的绑定有点棘手。您通常不会绑定到DataSet。绑定到DataSet中的DataTable,DataMember名称是要绑定到的表中的列。
You''ll have to update the database with the new item, then requery the database to retrieve the updated table.
BTW, your binding is a bit screwy. You normally don''t bind to a DataSet. You bind to a DataTable in the DataSet and the DataMember name is the column in the table you want to bind to.
这篇关于DataBound ListBox - 想要添加项目和更新DB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!