<div style="margin-removed 480px"> <asp:Label ID="Label1" runat="server" Text="First Name"></asp:Label> <asp:TextBox ID="txtfname" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label2" runat="server" Text="Last Name"></asp:Label> <asp:TextBox ID="txtlname" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label3" runat="server" Text="EmpId"></asp:Label> <asp:TextBox ID="txtempid" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label4" runat="server" Text="D O B"></asp:Label> <asp:TextBox ID="txtdob" runat="server"></asp:TextBox> <br /> <br /> <br /> <asp:Button ID="btnprev" runat="server" onclick="btnprev_Click" Text="<< Prev" /> <asp:Button ID="btnsave" runat="server" onclick="btnsave_Click" Text="Save" /> <asp:Button ID="btnnext" runat="server" onclick="btnnext_Click" Text="Next >>" /> <br /> <br /> <asp:Label ID="lblmsg" runat="server" Text=""></asp:Label> </div>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Web.Configuration; public partial class _Default : System.Web.UI.Page { DataTable dt; int i = 0; public void print() { DataRow dr = dt.Rows[i]; txtfname.Text = dr[0].ToString(); txtlname.Text = dr[1].ToString(); txtempid.Text = dr[2].ToString(); txtdob.Text = dr[3].ToString(); } protected void Page_Load(object sender, EventArgs e) { } protected void btnsave_Click(object sender, EventArgs e) { string connStr = WebConfigurationManager.ConnectionStrings["master"].ConnectionString; SqlConnection conn = new SqlConnection(connStr); conn.Open(); SqlCommand cmd = new SqlCommand("insert into employee values('" + txtfname.Text + "','" + txtlname.Text + "','" + txtempid.Text + "','" + txtdob.Text + "')", conn); cmd.ExecuteNonQuery(); conn.Close(); lblmsg.Text = "Successfully Registered"; } protected void btnprev_Click(object sender, EventArgs e) { i = 0; print(); } protected void btnnext_Click(object sender, EventArgs e) { i = dt.Rows.Count - 1; print(); } }
<configuration> <connectionstrings> <add name="Northwind" connectionString="Data Source=JAGADEESHWAR;Initial Catalog=master;Integrated Security=True" providerName="System.Data.SqlClient"/> </connectionstrings> <system.web> <compilation debug="true" targetFramework="4.0"/> </system.web> </configuration>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)