**如果我想添加来自ASP.NET Web表单中已实现的注册的名称,姓氏字段。我想遵循的步骤是什么?
以及如何使用ASP.NET Web表单
添加数据库的连接谢谢。**
您可以添加新字段:
<table class="auto-style1">
<tr>
<td class="auto-style2">First Name:</td>
<td class="auto-style3">
<asp:TextBox ID="fName" runat="server" Width="200px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="fName" ErrorMessage="* First name is required" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">Last Name:</td>
<td class="auto-style3">
<asp:TextBox ID="lName" runat="server" Width="200px"></asp:TextBox>
</td>
您将拥有一个提交按钮,因此您可以将此代码添加到提交按钮单击事件
protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("insert into "YOUR TABLE NAME" (firstName,
lastName) values ('" + fName.Text + "', '" + lName.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();
}
}