Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 1:41am
Edited 12-Jul-12 1:45am
v2
Comments
Tejas_Vaishnav at 12-Jul-12 6:46am
   
what is your db column data type for storing this two dropdwon's value.?
Rate this: bad
good
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 
  Permalink  
Comments
shinebudy at 12-Jul-12 6:49am
   
please explain me why you write 0 and 1
Rahul Rajat Singh at 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 at 12-Jul-12 6:51am
   
Perfect. 5.
Rahul Rajat Singh at 12-Jul-12 6:52am
   
thanks.
shinebudy at 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 at 12-Jul-12 6:59am
   
use the capital F in format. and if it doesnt work then tell me the error.
shinebudy at 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 at 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
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 230
2 BillWoodruff 205
3 Sergey Alexandrovich Kryukov 195
4 DamithSL 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,650
3 Kornfeld Eliyahu Peter 3,460
4 Sergey Alexandrovich Kryukov 2,811


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 12 Jul 2012
Copyright © CodeProject, 1999-2014
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