String strUIDNo; int count; int iRowCount = ds.Tables[0].Rows.Count - 1; if (iRowCount > -1) { strUIDNo = ds.Tables[0].Rows[iRowCount]["UIDNo"].ToString(); //count=strUIDNo.Length count = Convert.ToInt16(strUIDNo.Substring(3)); count++; txtNo.Text = "000" + count; } else { txtNo.Text = "0001"; }
string strOutput = ""; int idLength = strUIDNo.Substring(3).Length; if(idLength == 1) strOutput = "000" + count.ToString(); else if(idLength == 2) strOutput = "00" + count.ToString(); else if(idLength == 3) strOutput = "0" + count.ToString(); else strOutput = count.ToString(); then assign this value to your textbox. txtNo.Text = strOutput;
txtNo.Text = string.Format("####",count);
txtNo.Text = string.Format("{0:d4}", count);
txtNo.Text = count.ToString().PadLeft(4, '0');
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)