GridView在编辑时出现意外行为 [英] GridView makes Unexpected behavior while editing

查看:98
本文介绍了GridView在编辑时出现意外行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一些记录绑定到gridview,绑定过程正确完成,并且还添加了用于编辑和删除的命令字段.当我第一次编辑时,所有单元格的值都转到相应的文本框或其他控件,因此编辑工作非常完美.但是问题是当我在gridview中编辑另一条记录时,该行变成了类似于模板字段的文本框.请帮助我.我认为这是意外行为.


看一下屏幕截图,您会得到我的pblm

http://bit.ly/eg1YnS [ ^ ]

http://bit.ly/fEdKOQ [ ^ ]

更新:

I am binding some records to gridview, the binding process is done correctly and also iam adding commandfield for editing and deleting. When i am editing first time all the cell value go to the corresponding textboxes or other controls, editing is worked perfectly. But the problem is that when i am editing another record in the gridview the row become textboxes like template field.Please help me.I think this is an unexpected behaviour.


Look at the screenshot you get what is my pblm

http://bit.ly/eg1YnS[^]

http://bit.ly/fEdKOQ[^]

Update:

public bool Bind(string Query, GridView grdView) 
{
 sqlFunc = new DB.SQLFunctions();
 DataTable dTable = sqlFunc.ReturnDataTable(Query);
 grdView.DataSource = dTable;
 grdView.DataBind();
 return true;
 }



这是我只是调用此方法并且bind.iam多次执行此方法的方法.但是无法解决此pblm



This is the method iam just calling this method and bind.iam doing so many times this approach.but this pblm i can''t fix

推荐答案

我只能猜测的是,您是从Page_Load事件处理程序中调用Bind()方法的,而没有检查IsPostback属性.

如果您从Page_Load调用Bind()方法,请尝试

From the above scenario only thing I can guess is that you are calling the Bind() method from Page_Load event handler without checking IsPostback property.

If you call Bind() method from Page_Load, try like

if (!IsPostback)
{
    //YOUR CODE GOES HERE
    //
    Binding(YOUR_QUERY, gridView);
}


如果页面已加载,则数据将成功显示在页面中.您单击更新或重置按钮,所有工作完成,然后您的页面将被转移或重定向到同一页面.
if page is load then data is display successfully in page. you click the update or reset button, all work complete then you page is transfer or redirect to same page.


这篇关于GridView在编辑时出现意外行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆