我给datagrid加了editcommandcolumn单击编辑和取消有放映,单击更新就没放映了.tell me why?thanks
_______________________________________________________________________
html部分:
<asp:datagrid id="mydatagrid" headerstyle-backcolor="#E8C3BD" oneditcommand="mydatagrid_edit" oncancelcommand="mydatagrid_cancel" onupdatecommand="mydatagrid_update" datakeyfield="id"
width="480px" autogeneratecolumns="false" alternatingitemstyle-backcolor="#C3EBF4" itemstyle-backcolor="#ffffff" runat="server" >
<columns>
<asp:boundcolumn headertext="姓名" datafield="name" />
<asp:boundcolumn headertext="性别" datafield="sex"/>
<asp:boundcolumn headertext="学号" datafield="cmid" />
<asp:boundcolumn headertext="电话号码" datafield="phonenumber"/>
<asp:boundcolumn headertext="出生日期" datafield="birthday"/>
<asp:boundcolumn headertext="来自" datafield="comefrom"/>
<asp:editcommandcolumn edittext="编辑" updatetext="更新" canceltext="取消" />
</columns>
</asp:datagrid>
_______________________________________________________________________________
script部分:
sub mydatagrid_update(sender as object,e as datagridcommandeventargs)
dim conn as new oledbconnection("provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("../database/cmmessage.mdb"))
dim texname,texsex,texcmid,texphonenumber,texbirthday,texcomefrom as textbox
texname=e.item.cells(0).controls(0)
texsex=e.item.cells(1).controls(0)
texcmid=e.item.cells(2).controls(0)
texphonenumber=e.item.cells(3).controls(0)
texbirthday=e.item.cells(4).controls(0)
texcomefrom=e.item.cells(5).controls(0)
dim sql as string
sql="update resume set name='"& texname.text &"',sex='"& texsex.text &"',cmid="& cdbl(texcmid.text) &",phonenumber="& cdbl(texphonenumber.text) &",birthday='"& texbirthday.text &"',comefrom='"& texcomefrom.text &"' where id=" & mydatagrid.datakeys(cint(e.item.itemindex))
dim cmd as new oledbcommand(sql,conn)
conn.open()
cmd.executenonquery()
conn.close()
mydatagrid.edititemindex=-1
call binddata()
end sub
[此贴子已经被作者于2007-4-8 19:44:06编辑过]