Torna al Thread

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [tabella] WHERE [ID] = @ID" InsertCommand="INSERT INTO [tabella] ([Nome], [Cognome], [Indirizzo]) VALUES (@Nome, @Cognome, @Indirizzo)" SelectCommand="SELECT [ID], [Nome], [Cognome], [Indirizzo] FROM [tabella]" UpdateCommand="UPDATE [tabella] SET [Nome] = @Nome, [Cognome] = @Cognome, [Indirizzo] = @Indirizzo WHERE [ID] = @ID"> <DeleteParameters> <asp:Parameter Name="ID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="Nome" Type="String" /> <asp:Parameter Name="Cognome" Type="String" /> <asp:Parameter Name="Indirizzo" Type="String" /> <asp:Parameter Name="ID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="Nome" Type="String" /> <asp:Parameter Name="Cognome" Type="String" /> <asp:Parameter Name="Indirizzo" Type="String" /> </InsertParameters> </asp:SqlDataSource> </div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="SqlDataSource1"> <Columns> <asp:TemplateField HeaderText="ID" InsertVisible="False" SortExpression="ID"> <EditItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("ID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Nome" SortExpression="Nome"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Nome") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("Nome") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Cognome" SortExpression="Cognome"> <EditItemTemplate> <asp:Label ID="Label5" runat="server" Text='<%# Bind("Cognome") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Bind("Cognome") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Indirizzo" SortExpression="Indirizzo"> <EditItemTemplate> <asp:Label ID="Label6" runat="server" Text='<%# Bind("Indirizzo") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label4" runat="server" Text='<%# Bind("Indirizzo") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:CommandField ShowEditButton="True" /> <asp:CommandField ShowDeleteButton="True" /> </Columns> </asp:GridView> </form> </body> </html>
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5