You can problably use any one of the two approaches.
1. Create a static class like below
public static class SequentialNumber
{
private static int _currentNumber=0;
public static string GetNextNumber()
{
_currentNumber++;
return "C"+_currentNumber.ToString();
}
}
and then in insert buttons click, write a code like below to get the sequential number in the text box
string ContractNo=SequentialNumber.GetNextNumber();
2 approach.
Declare a variable _currentnumber in the code behind page
in the click event of the insert button write code as below.
if(string.IsNullOrEmpty(ViewStatte["Num"]))
_currentNumber=0;
else
{
_currentNumber=(int)ViewState["Num"];
}
_currentNumber++;
ViewState["Num"]=_currentNumber;
string ContractNo=_currentNumber;
Approach 1 can be used in all types of project where as approach 2 can be used in asp.net only.
Hope this helps.
--sunil