Connecting Tech Pros Worldwide Help | Site Map

concatenation of two dropdownlists

Newbie
 
Join Date: Sep 2009
Posts: 4
#1: 4 Weeks Ago
im using three dropdownlists to store year month date in database..
Expand|Select|Wrap|Line Numbers
  1.  string str = DropDownList5.SelectedItem.Value.ToString();
  2.         string str1 = DropDownList6.SelectedItem.Value.ToString();
  3.         string str2 = DropDownList7.SelectedItem.Value.ToString();
  4.         string final = str1 +"-"+ str+"-" + str2;
  5.  
  6. cmd.Parameters.Add("@startdate", SqlDbType.SmallDateTime.ToString()).Value = final;
  7.  
  8.  
this is working as i can save year month day in a single column(startdate) in table.
and retrieving that column using session and posting that value to other page..
while retriving i want year month date in seperate ddls any sample code plz....


Expand|Select|Wrap|Line Numbers
  1.  
  2. for single ddl ..
  3. DropDownList1.SelectedItem.Text = Session["startdate"].ToString();
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,066
#2: 4 Weeks Ago

re: concatenation of two dropdownlists


In the first piece of code you are saving a String (that contains the date) into a database...but it looks like the database is expecting a Date object??

In the second piece of code you are retrieving something from Session....

How are the 2 pieces of code related??? Session is not the same thing as your database.....

You could try using the DateTime object instead of Strings. That way you can easily access the Day/Month/Year (etc) values as you need them.

-Frinny
Reply