<%@ Page Language="C#" ClassName="Default_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
void Button1_Click(object sender, EventArgs e)
{
TextBox nome = GridView1.FooterRow.FindControl("nomeTextBox") as TextBox;
TextBox cognome = GridView1.FooterRow.FindControl("cognomeTextBox") as TextBox;
TextBox Username = GridView1.FooterRow.FindControl("UsernameTextBox") as TextBox;
TextBox Password = GridView1.FooterRow.FindControl("PasswordTextBox") as TextBox;
TextBox email = GridView1.FooterRow.FindControl("emailTextBox") as TextBox;
SqlDataSource1.InsertParameters["nome"].DefaultValue = nome.Text;
SqlDataSource1.InsertParameters["cognome"].DefaultValue = cognome.Text;
SqlDataSource1.InsertParameters["Username"].DefaultValue = Username.Text;
SqlDataSource1.InsertParameters["Password"].DefaultValue = Password.Text;
SqlDataSource1.InsertParameters["email"].DefaultValue = email.Text;
SqlDataSource1.Insert();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" Runat="server" DataSourceID="SqlDataSource1" DataKeyNames="nome"
AutoGenerateColumns="False" ShowFooter="True" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="nomeLabel" Runat="Server"><%# Eval("nome") %></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="nomeTextBox" Runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="cognomeLabel" Runat="Server"><%# Eval("cognome") %></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="cognomeTextBox" Runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="UsernameLabel" Runat="Server"><%# Eval("Username")%></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="UsernameTextBox" Runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="PasswordLabel" Runat="Server"><%# Eval("Password")%></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="PasswordTextBox" Runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="emailLabel" Runat="Server"><%# Eval("email")%></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="emailTextBox" Runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<FooterTemplate>
<asp:Button ID="Button1" Runat="server" Text="Add" OnClick="Button1_Click" />
</FooterTemplate>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" Runat="server"
InsertCommand="INSERT INTO [utenti] ([nome], [cognome], [Username], [Password], [email]) VALUES (@nome, @cognome, @Username, @Password, @email)"
SelectCommand="SELECT [nome], [cognome], [Username], [Password], [email] FROM [utenti]"
ConnectionString="<%$ ConnectionStrings

atabaseConnectionString %>">
<InsertParameters>
<asp:Parameter Name="nome" Type="String" />
<asp:Parameter Name="cognome" Type="String" />
<asp:Parameter Name="Username" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="email" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>