Click here to Skip to main content
15,907,492 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void btnClick_Register(object sender, EventArgs e)
    {
        RegisterdbDataContext ds = new RegisterdbDataContext();
        ds.StoreNewUsers(txtFirstName.Text, txtLastName.Text, txtEmailId.Text, txtPassword.Text, txtContactNumber.Text);
    }

I,m getting error on txtContactNumber.
Posted
Updated 3-Oct-15 21:39pm
v2
Comments
Member 12030955 4-Oct-15 0:16am    
I,m getting error on txtContactNumber.

StoreNewUsers might be having decimal parameter and you're passing string, that's why you're getting error.
C#
ds.StoreNewUsers(txtFirstName.Text, txtLastName.Text, txtEmailId.Text, txtPassword.Text, decimal.Parse(txtContactNumber.Text));

Give it a try.

-KR
 
Share this answer
 
If you are sure that txtContactNumber only allows numbers and it is mandatory field then use decimal.Parse
C#
decimal contactNumber = decimal.Parse(txtContactNumber.Text);

Secondly if you are not sure about txtContactNumber value means user can provide chars or blank value then for safety use decimal.TryParse
C#
decimal contactNumber;
bool isSuccess = decimal.TryParse(txtContactNumber.Text, out contactNumber);
 
Share this answer
 
Comments
Member 12030955 5-Oct-15 10:01am    
Ok let me give a try. . . thanks for the reply>>
Member 12030955 5-Oct-15 10:14am    
I,m getting an error saying user defined exception something

public void StoreNewUsers(string text1, string text2, string text3, string text4, string text5)
{
throw new NotImplementedException();
}
}
[no name] 5-Oct-15 10:18am    
Please provide method definition and method call to figure out the problem. And also what exact error you are getting.
Member 12030955 5-Oct-15 10:20am    
I,m unable to store my data in database when i hit submit button. It automatically creates a user defined exception & says user defined exception not handled by the user
[no name] 5-Oct-15 10:24am    
As I told you need to provide code for method definition and method call what exactly you are passing. Secondly I have no idea what your database column data type. Provide all info to resolve the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900