Model.Sell sell = new Model.Sell();
BindingSource bindingSource = new BindingSource();
private void btnAdd_Click(object sender, EventArgs e)
{
sell.ID=1;
sell.Name=tbxName.Text;
bindingSource.Add(sell);
BindData();
private void BindData()
{
DataGridView1.DataSource=bindingSource;
}
private DataTable ConvertToDataTable()
{
DataTable dt = new DataTable();
string json = Newtonsoft.Json.JsonConvert.SerializeObject(bindingSource.List);
dt = JsonConvert.DeserializeObject<DataTable>(json);
return dt;
}
No comments:
Post a Comment