Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I created one web page and that page contain name, title, description and mobile number or landline number

here once enter name , title, description, and mobile number or landline number after entering these store in database table and

enter only name, title, description, not enter mobile or landline number here i want optional mobile number or landline and store in database table please reply me any examples or logic please reply me
Posted
Updated 20-Apr-14 23:13pm
v2
Comments
OriginalGriff 21-Apr-14 5:21am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

1 solution

try this...
C#
objLiftingEntryPL.Mobileno = txtmobile.Text.Trim() == "" ? null : txtmobile.Text.Trim();

observe above line...If you enter mobile number it takes the Mobile Number from user other wise it stores the NULL value in your datebase..similarily write above line as same as 
"TxtLandNumber" ...
 
Share this answer
 
v2
Comments
member258 21-Apr-14 5:24am    
here error comming : objLiftingEntryPL this is what please reply me
Siva Hyderabad 21-Apr-14 5:29am    
first send me your button click logic
Siva Hyderabad 21-Apr-14 6:01am    
if condition
String strInsert = "insert into ProductDetailsTable(Categories,CategoriesType,Title,Description,Price,State,City,ContactName,ContactEmail,ContactMobile,ContactPhoto,ContactedViaEmail,ContactedViaMobile,DateAdded) values('" + lblEducation.Text + "','" + ddlCategoryType.Text + "','" + txtTitle.Text + "','" + txtDescription.Text + "','" + txtPrice.Text + "','" + ddlState.SelectedItem.Text + "','" + ddlCity.SelectedItem.Text + "','" + txtContactName.Text + "','" + txtContactEmail.Text + "','" + txtContactMobile.Text.Trim() == "" ? null : txtContactMobile.Text.Trim(); +"','" + strimage + "','" + txtContactedViaEmail.Text + "','" + txtContactedViaMobile.Text.Trim() == "" ? null : txtContactedViaMobile.Text.Trim(); +"','" + lblDateTime.Text + "')";

You just changed this line
Siva Hyderabad 21-Apr-14 6:01am    
else condition

String strInsert = "insert into ProductDetailsTable(Categories,CategoriesType,Title,Description,Price,State,City,ContactName,ContactEmail,ContactMobile,ContactPhoto,ContactedViaEmail,ContactedViaMobile,DateAdded)values('" + lblEducation.Text + "','" + ddlCategoryType.Text + "','" + txtTitle.Text + "','" + txtDescription.Text + "','" + txtPrice.Text + "','" + ddlState.SelectedItem.Text + "','" + ddlCity.SelectedItem.Text + "','" + txtContactName.Text + "','" + txtContactEmail.Text + "','" + txtContactMobile.Text.Trim() == "" ? null : txtContactMobile.Text.Trim(); +"','" + strimage + "','" + txtContactedViaEmail.Text + "','" + txtContactedViaMobile.Text.Trim() == "" ? null : txtContactedViaMobile.Text.Trim(); +"','" + lblDateTime.Text + "')";
Siva Hyderabad 21-Apr-14 6:45am    
you just copy above two lines

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