Saturday, 19 November 2011

Increment looping starts from '00' Like 001 to 096...

increment looing
 
SqlCommand cmd1 = new SqlCommand("select * from tbMemberRegistration where MemberShipNo like (@check)", cstring);
string dd = (LastNameTextBox.Text.Substring(0, 1) + "%").ToString();
cmd1.Parameters.Add("@check",SqlDbType.VarChar).Value = (LastNameTextBox.Text.Substring(0, 1) + "%").ToString();
                              SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
int count = Convert.ToInt32(ds1.Tables[0].Rows.Count.ToString());
if (ds1.Tables[0].Rows.Count == 0)
{
//Labelexd.Text = LastNameTextBox.Text.Substring(0, 1);
string st = LastNameTextBox.Text.ToUpper().Substring(0, 1);
code = st + "00" + (count + 1);
}
if (count > 0 && count < 9)
{
string st = LastNameTextBox.Text.ToUpper().Substring(0, 1);
code = st + "00" + (count + 1);
}
if (count >= 9 && count < 99)
{
string st = LastNameTextBox.Text.ToUpper().Substring(0, 1);
code = st + "0" + (count + 1);
}
if (count >= 99 && count < 999)
{
string st = LastNameTextBox.Text.ToUpper().Substring(0, 1);
code = st + (count + 1);
}

No comments:

Post a Comment

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...