Grazie per la risposta.
Sai dirmi come recuperare i valori per fare poi l'update?
mi da errore qua:
Riga 52: clinome=e.item.cells.(1) e mi dice è previsto un identificatore.
Come posso fare a recuperare i valori del datagrid per fare poi l'upload?
codice:
<%@ Page Language="VB" %>
<%@ import Namespace="System.data.oleDb" %>
<%@ import Namespace="System.data" %>
<script runat="server">
dim cmd as oledbcommand
dim dtr as oledbdatareader
Dim myConn As OleDbConnection
Dim myOleDbAdapter As OleDbDataAdapter
Dim connStr, sqlStr As String
Dim myDataSet As New Dataset
Sub Page_Load(src As Object, e As EventArgs)
connStr="Provider=Microsoft.Jet.OLEDB.4.0;" _
+"Data Source="+Server.MapPath("/mdb-database/db.mdb")
myConn= New OleDbConnection(connStr)
if not ispostback then
ordina("nome")
end if
end sub
sub ordina (campo as string )
myConn.Open()
sqlstr="select * from clienti order by " & campo
cmd=new oledbcommand( sqlstr,myconn)
dtr= cmd.executereader()
clienti.datasource=dtr
clienti.databind()
dtr.close()
myconn.close()
end sub
sub seleziona (s as object ,e as datagridsortcommandeventargs )
ordina (e.sortexpression)
end sub
sub modifica (s as object ,e as datagridcommandeventargs )
clienti.EditItemIndex = e.Item.Itemindex
ordina ("nome")
end sub
sub aggiorna (s as object ,e as datagridcommandeventargs )
dim clinome as textbox
dim idcliente as integer
idcliente= clienti.datakeys (e.item.itemindex)
clinome=e.item.cells.(1)
sqlstr ="update clienti set nome='" & clinome.text & " where idcliente=" & idcliente
myConn.Open()
cmd=new oledbcommand( sqlstr,myconn)
dtr= cmd.executereader()
clienti.datasource=dtr
clienti.databind()
dtr.close()
myconn.close()
ordina ("nome")
end sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="clienti" runat="server" CellPadding="10" OnSortcommand="seleziona" AutoGenerateColumns="False" onupdatecommand="aggiorna" oneditcommand="modifica">
<Columns>
<asp:BoundColumn DataField="idcliente" HeaderText="idcliente" />
<asp:BoundColumn DataField="nome" HeaderText="nome" />
<asp:EditCommandColumn UpdateText="aggiorna!" CancelText="cancella" EditText="Edit!" />
</Columns>
</asp:DataGrid>
</form>
</body>
</html>