Hi JOYSON,
Refer below links and implement in your code.
Refer the below sample.
<asp:TextBox ID="txtId" runat="server"></asp:TextBox>
C#
protected void Page_Load(object sender, EventArgs e)
{
NewId();
}
private void NewId()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("SELECT MAX(EmployeeID) + 1 as Id FROM Employees", con);
txtId.Text = cmd.ExecuteScalar().ToString();
con.Close();
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
NewId()
End Sub
Private Sub NewId()
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings(1).ConnectionString)
con.Open()
Dim cmd As New SqlCommand("SELECT MAX(EmployeeID) + 1 as Id FROM Employees", con)
txtId.Text = cmd.ExecuteScalar().ToString()
con.Close()
End Sub
Output is display as increment by 1 each time based on database record on page load.