我的更新是这样的。 dim mybox as textbox
dim myprice as string
mybox=e.item.findcontrol("price")
myprice=mybox.text
'response.write(myprice)
dim myconn as new oledbconnection(connstr)
dim mycom as oledbcommand
dim sql as string
sql="update guestbook set mynum="& myprice &" where id = "& (e.item.itemindex)
mycom=new oledbcommand(sql,myconn)
myconn.open()
mycom.executeNonQuery
myconn.close()
mydatagrid.edititemindex=-1
binddata
这是根据书上的来的,没错,这样是可以执行,但是并不正确。因为id并不一定=e.item.itemindex,比如中间少一条记录就错位了
所以我想问问大家怎样能提出来所在行的id的值。
谢谢。Datagrid中的一部分
<columns>
<asp:boundcolumn datafield="id" headertext="序号" headerstyle-width=50 readonly />
dim myprice as string
mybox=e.item.findcontrol("price")
myprice=mybox.text
'response.write(myprice)
dim myconn as new oledbconnection(connstr)
dim mycom as oledbcommand
dim sql as string
sql="update guestbook set mynum="& myprice &" where id = "& (e.item.itemindex)
mycom=new oledbcommand(sql,myconn)
myconn.open()
mycom.executeNonQuery
myconn.close()
mydatagrid.edititemindex=-1
binddata
这是根据书上的来的,没错,这样是可以执行,但是并不正确。因为id并不一定=e.item.itemindex,比如中间少一条记录就错位了
所以我想问问大家怎样能提出来所在行的id的值。
谢谢。Datagrid中的一部分
<columns>
<asp:boundcolumn datafield="id" headertext="序号" headerstyle-width=50 readonly />
但是我想延伸一下假设想更新的条件不是一个条件,而是多个条件,应该怎样?
比如类似update guestbook where name='xxx' and cateid=5应当如何?谢谢!