Q:

Show numeric textbox value with leading zeros

I have 3 text box values as:
no of requests = 2
court fee = 60
claim amount = 200

My client requirment would like them to show:
no of requests = 00002; // 5 characters
court fee = 000006000; // 9 characters
claim amount = 0000020000; // 10 characters

I tried this but not getting those values. I dont know where am I going wrong.
decimal requests = 0;
decimal CFee = 0;
decimal CLAIMAMT = 0;

for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
    CFee += Convert.ToDecimal(dataGridView1.Rows[i].Cells["CFee"].Value) / 100 * dataGridView1.RowCount;
    CLAIMAMT += Convert.ToDecimal(dataGridView1.Rows[i].Cells["CLAIMAMT"].Value) / 100 ;
    requests = Convert.ToInt16(dataGridView1.RowCount.ToString());
}

textBox3.Text = CFee.ToString();//court fee
textBox4.Text = CLAIMAMT.ToString();//claim amoiunt
textBox2.Text = requests.ToString();//no 

A:

Don't use decimal for whole numbers.  Use int for whole numbers and decimal for currency amounts and the like.  If you want leading zeroes then you can do so like this:
var str = number.ToString("00000"); // At least five digits with leading zeroes if required.

A:

You can try using String.Format
For example, to add zeroes before a number, use colon separator : and write as many zeroes as you want.
String.Format("{0:00000}", 2);          // "00002"
String.Format("{0:D5}", 2);             // "00002"
String.Format("{0:D9}", 6000);          // "000006000"

A:

Try the PadLeft method. It will append as many of the character you specify to the left of the string until it reaches the length given in the 1st parameter.
textBox3.Text = CFee.ToString().PadLeft(5, '0');

