// automatically generate the number and incremented in TextBox Field (C# and ASP.NET)
The Code is Shown Below...
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT COUNT(ProposalNumber) as Tot FROM Proposals", con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
while (dr.Read())
{
int i = Convert.ToInt32(dr["tot"]);
if (i > 0)
{
int j = i + 1;
TextBox1.Text = "00" + j.ToString();
}
else
{
TextBox1.Text = "00";
}
}
con.Close();
}
No comments:
Post a Comment