teo prome ha scritto:
no panic
si certo gli metti il parameter ID, ma cosa prende visto che in realtà non editi ID?
DataKeyNames="ID"
http://www.aspitalia.com/script/671/GridView-AccessDataSource-Accesso-Dati-ASP.NET-2.0.aspx
che poi è stessa cosa
http://msdn.microsoft.com/en-us/library/ms972948.aspx
Grazie, ho aggiunto anche DataKeyNames="ID", ma niente non esegue l'update... continua ad estrarre ed a eliminare i record correttamente... (sono tornato al codice non semplificato, ma è lo stesso...)
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnMySQL %>"
ProviderName="<%$ ConnectionStrings:ConnMySQL.ProviderName %>"
SelectCommand="SELECT * FROM tbl_login"
DeleteCommand="DELETE FROM tbl_login WHERE ID=?"
UpdateCommand="UPDATE tbl_login SET nome=?, cognome=? WHERE ID=?"
OldValuesParameterFormatString="{0}"
DataSourceMode="DataSet">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" Direction="Input" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" Direction="Input" />
<asp:Parameter Name="nome" Type="String" Direction="Input" />
<asp:Parameter Name="cognome" Type="String" Direction="Input" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSource1"
DataKeyNames="ID"
AllowSorting="True"
AllowPaging="True"
PageSize="20"
AutoGenerateColumns="false">
<PagerStyle HorizontalAlign="Left" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="true" InsertVisible="False" SortExpression="ID" />
<asp:BoundField DataField="Email" HeaderText="Email" HtmlEncode="False"
DataFormatString="<a href='mailto:{0}'>{0}</a>" />
<asp:BoundField DataField="nome" HeaderText="nome" ApplyFormatInEditMode="True"
DataFormatString="{0:d}" HtmlEncode="False" />
<asp:BoundField DataField="cognome" HeaderText="cognome" />
<asp:CommandField ShowHeader="true" HeaderText="Modifica" ShowEditButton="true" />
<asp:CommandField ShowHeader="true" HeaderText="Elimina" ShowDeleteButton="true" />
<asp:TemplateField>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Position="TopAndBottom" FirstPageText="Prima pagina"
LastPageText="Ultima pagina" Mode="NextPreviousFirstLast" />
<PagerSettings />
</asp:GridView>