当前位置:编程学习 > C#/ASP.NET >>

dataGridView的绑定问题


if (SqlDal.InsertUser_Info(userName, userAdd, userZhangHao, userTel, kaiTongRiQi, jieShuRiQi, Money, Zhao, BeiZhu, SheBeiDuanKou))
                {
                    Isnert_Update = true;

                    //BangDing();
                    // dataGridView重新绑定
                    this.dataGridView1.DataSource = SqlDal.GetAll_T_User_Info();
                    this.txtUserName.Text = "";
                    this.txtAdd.Text = "";
                    this.txtUserZangHao.Text = "";
                    this.txtTel.Text = "";
                    this.datKaiTime.Value = DateTime.Now;
                    this.datJieTime.Value = DateTime.Now;
                    this.txtMomey.Text = "";
                    this.txtZhao.Text = "";
                    this.txtBeiZhu.Text = "";
                    this.txtDuanHao.Text = "";


                    MessageBox.Show("保存成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

为什么我的代码在调试的时候插入成功之后dataGridView会直接绑定上一条新数据了
但是在发布之后他就绑定不上,要把界面关闭之后再打新数据就会绑定上了(加载的时候用同样方法绑定的) --------------------编程问答-------------------- this.dataGridView1.DataSource = SqlDal.GetAll_T_User_Info();
你仔细看看这句吧 --------------------编程问答-------------------- this.dataGridView1.DataSource = SqlDal.GetAll_T_User_Info();
this.dataGridView1.DataBind();
try it --------------------编程问答-------------------- 重新调用databind()上面的应该可以解决 --------------------编程问答--------------------
引用 1 楼 sandy945 的回复:
this.dataGridView1.DataSource = SqlDal.GetAll_T_User_Info();
你仔细看看这句吧

这个没有问题 我肯定 --------------------编程问答-------------------- this.dataGridView1.dataBind()
加上就应该没有问题了~~ --------------------编程问答--------------------
引用 5 楼 ginni215 的回复:
this.dataGridView1.dataBind()
加上就应该没有问题了~~


up --------------------编程问答-------------------- 重新绑定一下就可以了 --------------------编程问答--------------------
引用 5 楼 ginni215 的回复:
this.dataGridView1.dataBind()
加上就应该没有问题了~~


在winform里没这东西吧 --------------------编程问答--------------------
引用 5 楼 ginni215 的回复:
this.dataGridView1.dataBind()
加上就应该没有问题了~~


在winform里没这东西吧
补充:.NET技术 ,  .NET Framework
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,