Click here to Skip to main content
13,143,637 members (28,496 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i take two dropdopdown for age

here is my concatnation

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 12-Jul-12 0:41am
Updated 12-Jul-12 0:45am
Tejas_Vaishnav 12-Jul-12 6:46am
what is your db column data type for storing this two dropdwon's value.?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try this

string ageRange = string.format("{0} to {1}", ddlAgeFrom.SelectedValue, ddlAgeTo.SelectedValue);
//push ageRange to DB now 
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
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
Rahul Rajat Singh 12-Jul-12 6:59am
use the capital F in format. and if it doesnt work then tell me the error.
shinebudy 12-Jul-12 7:06am
hey rahul its work thank you very very much
if i further any error than i contact you if you have convenient ?
Rahul Rajat Singh 12-Jul-12 7:35am
you are most welcome. Always happy to help fellow developers. post your queries here on CP only. you will find a lot of experts here.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 12 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100