Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had three dropdown list like date,mounth,year I getting this list values from database.After getting this valuesfrom user i want send to database

my code
<asp:DropDownList ID="date" runat="server"></asp:DropDownList><asp:DropDownList ID="mounth" runat="server"></asp:DropDownList><asp:DropDownList ID="year" runat="server"></asp:DropDownList>

.cs code
MIDL
sqlcon.Open();
        adap = new SqlDataAdapter("select date from dof", sqlcon);
        ds = new DataSet();
        adap.Fill(ds);
        date.DataSource = ds;
        date.DataTextField = "date";
        date.DataBind();
        sqlcon.Close();
        sqlcon.Open();
        adap = new SqlDataAdapter("select mounth from dof", sqlcon);
        ds = new DataSet();
        adap.Fill(ds);
        mounth.DataSource = ds;
        mounth.DataTextField = "mounth";
        mounth.DataBind();
        sqlcon.Close();
        sqlcon.Open();
        adap = new SqlDataAdapter("select year from dof", sqlcon);
        ds = new DataSet();
        adap.Fill(ds);
        year.DataSource = ds;
        year.DataTextField = "year";
        year.DataBind();
        sqlcon.Close();

how to insert this values into data base
Posted
Updated 3-May-11 20:47pm
v2
Comments
Ashishmau 4-May-11 2:33am    
be clear what u want
evigneesh 4-May-11 2:39am    
how to insert drop down list selected values in to data base like table name date mounth year

1 solution

Your question is not clear. What is your requirement. Means do u want to save all the three values separtely or as the date.

DateTime SelectedDate = new DateTime(Convert.ToInt32(year.SelectedItem.Value), Convert.ToInt32(month.SelectedItem.Value), Convert.ToInt32(date.SelectedItem.Value));

But you can like that
 
Share this answer
 
Comments
evigneesh 4-May-11 2:42am    
thanks
i had an question how to insert drop down list selected values in to data base like table name date mounth year if submit button is click

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