I want generate a auto number in asp.net which must start as Cust. For example Cust/00001

Recommended Answers

Try the following sample:

string finalstr = "Cust/00000";
        for (int i = 0; i < 10; i++) 
        {
            string val = finalstr.Substring(5, finalstr.Length - 5);

            int newnumber = Convert.ToInt32(val) + 1;

            finalstr = "Cust/" + newnumber.ToString("00000");
        }
Jump to Post

All 2 Replies

Try the following sample:

string finalstr = "Cust/00000";
        for (int i = 0; i < 10; i++) 
        {
            string val = finalstr.Substring(5, finalstr.Length - 5);

            int newnumber = Convert.ToInt32(val) + 1;

            finalstr = "Cust/" + newnumber.ToString("00000");
        }

thanks it work for me. but now I want read database and get highest number and then +1 for next number.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.