如何在没有 SQLAdapter 的情况下使用 DatagridView 进行更新
我正在为其中一个网页创建一个后端。后端是 C# 中的 Windows 窗体。
我有一个业务对象 PaymentExpected:
public class PaymentExpected
{
public int ID { get; set; }
public int JoiningID { get; set; }
public int AccountID { get; set; }
.....
public List<PaymentExpected> Load_All()
{
....
}
为了填充我的 DataGridView,我只是这样做:
DG_View.DataSource = paymentExpected.Load_All();
现在我希望在单击“更新”按钮后保存更新,但我不想在使用业务对象时使用 SQL 适配器。
所以我需要某种方式来获取更改并调用更新。 (我通常会这样更新:)
paymentExpected.ID = 1;
paymentExpected.JoiningID = 1;
paymentExpected.AccountID = 1;
paymentExpected.Save();
但我不确定如何使用 datagridview 做到这一点?
I'm creating a backend for one of webpage. The backend is a Windows Form in C#.
I have a Business Object PaymentExpected:
public class PaymentExpected
{
public int ID { get; set; }
public int JoiningID { get; set; }
public int AccountID { get; set; }
.....
public List<PaymentExpected> Load_All()
{
....
}
And to fill my DataGridView I just do:
DG_View.DataSource = paymentExpected.Load_All();
now I want updates to be saved once the "Update" Button is clicked, But I dont want to use a SQL adapter as I use business objects.
So I need some way of getting the changes and calling the update. (Which I would normally update like this:)
paymentExpected.ID = 1;
paymentExpected.JoiningID = 1;
paymentExpected.AccountID = 1;
paymentExpected.Save();
But I am unsure of how to do that with the datagridview?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不能在代码隐藏中保留对“ paymentExpected.Load_All()”数据源的引用并从按钮单击事件中调用 paymentExpected.Save() ?
Why can't you just keep a reference to the "paymentsExpected.Load_All()" data source in the code-behind and call paymentExpected.Save() from the button click event?