我有下面的代码,它想要做什么是更新时,我从一个单独的表单添加新的记录到我的表,现在我得到所有的表数据,但如果我添加新的数据,它是在这里不可见,但保存在表格中,我必须关闭该程序并再次运行,才能使保存的数据在datagridview中可见。我的问题是我如何更新datagridview,以便表格信息始终在那里。 代码中,我有如下:更新datagridview
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace project
{
public partial class frmViewBookings : Form
{
public frmViewBookings()
{
InitializeComponent();
}
private void btnClose_Click(object sender, EventArgs e)
{
Form3 mainpage = new Form3();
mainpage.Show();
this.Close();
}
private void frmViewBookings_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'usersDataSet1.Booking' table. You can move, or remove it, as needed.
this.bookingTableAdapter.Fill(this.usersDataSet1.Booking);
}
}
}
你叫'.DataBind()'更新后? – DGibbs 2013-03-27 16:52:19
“绑定看起来像”是什么?你可以显示你在哪里声明'usersDataSet1'看起来像是在这里丢失了一些代码 – MethodMan 2013-03-27 16:52:27
嗯......我想我很困惑,@DJKRAZE-我只是简单地从工具箱中添加了datagridview,然后简单地选择了数据源。这是我所做的 – bandaa 2013-03-27 16:57:38