菜鸟问题:怎么用Button把GridView的数据更新?
using (_OverTimeTableAdapters.OverTimePayTableAdapter adp = new _OverTimeTableAdapters.OverTimePayTableAdapter())
{
foreach (DataRow drr in GridView2.Rows)
{
DropDownList ddl = GridView2.FindControl( "DropDownList1 ") as DropDownList;
decimal Mul = Convert.ToDecimal(ddl.Text);
Label lb = GridView2.FindControl( "Label1 ") as Label;
Guid pay = new Guid(lb.ToString());
adp.UpdateQuery(Mul, pay);
}
我是这样写的。
怎么改?注意button是在GridView外面的。实现整个GridView一起更新
------解决方案--------------------帮顶~记得留1分给我哦。
昨晚通宵,太困了~~~
------解决方案--------------------
每次做完修改后都要重新绑定控件,否则控件还是显示之前的数据,比如修改按钮中最后一航代码需要重新绑定,一般都是把GridView.Souve=XX,GridView.bind()这两个放在一起,然后每次做任何修改后调用。
------解决方案--------------------DropDownList ddl = GridView2.FindControl( "DropDownList1 ") as DropDownList;
if(ddl ! = null)
decimal Mul = Convert.ToDecimal(ddl.SelectValue); //ddl.SelectItem.Text
Label lb = GridView2.FindControl( "Label1 ") as Label;
if(lb != null)
Guid pay = new Guid(lb.Text);