How to ignore the whole beginning at 0

I am working on a web application. I have two text fields, one is txtEmployeeID and one is txtEmployeeName . What I'm trying to do here is when the user enters EmployeeID at txtEmployeeID , the employee name will appear in txtEmployeeName . So far, this part has worked. However, if an EmployeeID starts with bunch 0 , say 00000345 , the user needs to enter all 00000345 into EmployeeID to show that employeeName . I am wondering if there is a way for the user to simply enter 345 , and then that 00000345 employeeName will appear in txtEmployeeName ? Help will be received.

Example

 EmployeeID EmployeeName 00000345 James Murray 

In the text box.

 Employee ID: 345 

He will display

 Employee Name: James Murray 

My db query

 @Employee_ID varchar(8) = NULL SELECT s.Employee_ID, p.FIRST_NAME, p.LAST_NAME FROM [dbo].[Employee] e INNER JOIN [dbo].[Person] p ON e.PERSON_ID = p.PERSON_ID WHERE p.Employee_ID = @Employee_ID 
+6
source share
4 answers

try it

 int num = Convert.ToInt32(txtEmployeeID.Text); string idNum = num.ToString("00000000"); txtEmployeeID.Text = idNum.ToString(); 
+9
source

You can use Int32.ToString ("000") to format an integer in this way. See Custom Number Format Strings and Int32.ToString for details.

txtEmployeeID.text.ToString("00000000") == EmployeeID;

+2
source

You can do it as follows:

 string EmplId = txtEmployeeID.Text; EmplId = EmplId.TrimStart(new Char[] { '0' } ) 
0
source

I am responding to your request, assuming that the length of the EmployeeID is fixed (on your question 8)

Allows the user to enter employeeID in a text field without zeros

Use the following C # code to add leading zeros to your parameter before sending it to the database query.

string EmployeeID = String.Format ("{0: 00000000}", int.Parse (txtEmployeeID.ToString ())). ToString ();

0
source

All Articles