问题描述
用GridView的模板对数据进行编辑和修改,如何用Attributes.Add("OnClick","returnCheck()");方法在前台检查我更新时输入的数据是否正确?Check中的参数又要如何传递?我已经用RowCreated和RowDataBound事件,但不知道应该如何下手。
解决方案
解决方案二:
protectedvoidgvAddress_RowDataBound(objectsender,GridViewRowEventArgse){e.Row.Attributes.Add("onmousemove","this.style.cursor='default'");}一个简单的例子。
解决方案三:
.cs:protectedvoidGridView1_RowDataBound(objectsender,GridViewRowEventArgse){stringid="2";e.Row.Attributes.Add("onclick","returnCheck("+id+");");}HTML:<htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>UntitledPage</title><scripttype="text/javascript">functionCheck(id){alert(id);}</script></head><body><formid="form1"runat="server"><div><asp:GridViewID="GridView1"runat="server"OnRowDataBound="GridView1_RowDataBound"></asp:GridView></div></form></body></html>