Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i take two dropdopdown for age

here is my concatnation

C#
Convert.ToInt32(ddlAgeFrom.SelectedValue) + Convert.ToInt32(ddlAgeTo.SelectedValue)


i want to store in my database like 18 to 25 how can i do that
Posted
Updated 12-Jul-12 0:45am
v2
Comments
Tejas Vaishnav 12-Jul-12 6:46am    
what is your db column data type for storing this two dropdwon's value.?

Try this

C#
string ageRange = string.format("{0} to {1}", ddlAgeFrom.SelectedValue, ddlAgeTo.SelectedValue);

//push ageRange to DB now 
 
Share this answer
 
Comments
shinebudy 12-Jul-12 6:49am    
please explain me why you write 0 and 1
Rahul Rajat Singh 12-Jul-12 6:51am    
These are placeholders, {0} will be replaces by the forst string value after the comma and {1} will be replaced by 2nd. basically it will treat all the variables after comma as an array and use the placeholder number as index and start pushing the data in string and return a temp string.

so the ageRange will reallu contain 80 to 25 after this statement execute.
Abhinav S 12-Jul-12 6:51am    
Perfect. 5.
Rahul Rajat Singh 12-Jul-12 6:52am    
thanks.
shinebudy 12-Jul-12 6:57am    
string Height = string.format("{0} to {1}", ddlHeightFrom.SelectedValue, ddlHeightTo.SelectedValue);
i write it my for my height filed but it return error
how can i solve help me
You can concatenate the two fields with a "to" between them.
This can be done both at the ASP.Net or database level, depending on where you would want to place this logic.
 
Share this answer
 

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