1. Web Form

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="updaterecord.aspx.cs" Inherits="updaterecord" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<br />
<table border="1" style="width:100%; background-color:#123456; color:White"><tr><td>

    <h3 style="text-align:center; color:White">UPDATE EMPLOYEE RECORD</h3>
    
<table cellspacing="10" style="margin:auto">
<tr><td colspan="2">Enter employee ecode <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Search" onclick="Button1_Click" /></td></tr>
<tr>
<td><asp:Label ID="Label1" runat="server" ForeColor="White" Text="ECODE"></asp:Label></td>
<td><asp:TextBox ID="TextBox2" runat="server" Width="300" ReadOnly="true" ForeColor="DimGray"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="Label6" runat="server" ForeColor="White" Text="ENAME"></asp:Label></td>
<td><asp:TextBox ID="TextBox3" runat="server" Width="300"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="Label7" runat="server" ForeColor="White" Text="EDEPT NAME"></asp:Label></td>
<td><asp:TextBox ID="TextBox4" runat="server" Width="300"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="Label9" runat="server" ForeColor="White" Text="DOB"></asp:Label> 
    
</td>
<td><asp:TextBox ID="TextBox5" runat="server" Width="300"></asp:TextBox></td>
</tr>
<tr align="right">
<td colspan="2"><asp:Label ID="Label10" runat="server"></asp:Label>
<asp:Button ID="Button2" runat="server" Text="Update" onclick="Button2_Click" 
        style="height: 26px" ></asp:Button><br />     
        </td>
 </tr>
</table>   
 
 </td></tr></table>   
</asp:Content>

2. Web.Config

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
    <connectionStrings>
  <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
   providerName="System.Data.SqlClient" />
 </connectionStrings>
 <system.web>
		<compilation debug="true" targetFramework="4.0"/>
	</system.web>
</configuration>

3. Code Behind

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.Configuration;


public partial class updaterecord : System.Web.UI.Page
{
  
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        bool b; int emp;
        SqlConnection cnn = new SqlConnection();
        cnn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "select * from employee where ecode=@ecode";
        b=int.TryParse(TextBox1.Text, out emp );
        if (b == true)            
        {
            cmd.Parameters.AddWithValue("@ecode", emp);
            if (TextBox1.Text != "")
            {
                cmd.Connection = cnn;
                SqlDataAdapter adp = new SqlDataAdapter();
                DataSet dst = new DataSet();
                adp.SelectCommand = cmd;

                adp.Fill(dst, "employee");
                if (dst.Tables["employee"].Rows.Count != 0)
                {
                    TextBox2.Text = (dst.Tables["employee"].Rows[0][0]).ToString();
                    TextBox3.Text = (dst.Tables["employee"].Rows[0][1]).ToString();
                    TextBox4.Text = (dst.Tables["employee"].Rows[0][2]).ToString();
                    TextBox5.Text = (dst.Tables["employee"].Rows[0][4]).ToString();
                    Label10.Text = "";
                }

                else
                {
                    Label10.Text = "Record not found";
                    Label10.ForeColor = System.Drawing.Color.Red;
                    TextBox2.Text = "";
                    TextBox3.Text = "";
                    TextBox4.Text = "";
                    TextBox5.Text = "";
                }
            }
            else
            {
                Label10.Text = "Please enter ecode";
                Label10.ForeColor = System.Drawing.Color.Red;
                TextBox2.Text = "";
                TextBox3.Text = "";
                TextBox4.Text = "";
                TextBox5.Text = "";
            }
        }
        else
        {
            Label10.Text = "Enter only numeric";          
            Label10.ForeColor = System.Drawing.Color.Red;
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox4.Text = "";
            TextBox5.Text = "";
            TextBox1.Text = "";
        }
            
       
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        SqlConnection cnn = new SqlConnection();
        cnn.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "Update employee set ename=@ename, edep=@edep, dob=@dob where ecode=@ecode";
        cmd.Parameters.AddWithValue("@ecode", TextBox2.Text);
        cmd.Parameters.AddWithValue("@ename", TextBox3.Text);

        cmd.Parameters.AddWithValue("@edep", TextBox4.Text);
        cmd.Parameters.AddWithValue("@dob", TextBox5.Text);
        if (TextBox2.Text != "" && TextBox3.Text != "" && TextBox4.Text != "" && TextBox5.Text != "")
        {
        cmd.Connection = cnn;
        cnn.Open();
        int r = cmd.ExecuteNonQuery();
        if (r != 0)
        {
            Label10.Text = "Record successfully updated";
            Label10.ForeColor = System.Drawing.Color.Green;
        }
        cnn.Close();
        }

        else
        {
            Label10.Text = "Search field required";
            Label10.ForeColor = System.Drawing.Color.Red;
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox4.Text = "";
            TextBox5.Text = "";
            TextBox1.Text = "";
        }
       
    }
   
}


4. Run the program

updet_ado.net

5. Enter employee code which you want to update & click to search button..

updet_ado.net2

6. Edit field & click update button

updet_ado.net3

 

7. Check your database

updet_ado.net4