Click here to Skip to main content
15,791,846 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
string con_str = @"Data Source=DATABASE;Initial Catalog=abc;Integrated Security=True";
        protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)
                SqlConnection con = new SqlConnection(con_str );

                string es = "select year from table1";
                SqlCommand ees = new SqlCommand(es, con);
                SqlDataReader rdr = ees.ExecuteReader();

                while (rdr.Read())



now i want to add this dropdown value to another table in a new column

for example


sql roll name year(new column added)
1 222 abx 2011
2 333 eeqa 2011
3 342 bdh 2011

i will select 2011 and this will populate in the table in all the rows
Updated 7-Aug-14 2:12am
Karthik Harve 7-Aug-14 7:21am    
Have you tried using "Selected Index Changed" event of dropdown list ? On this event just update the database table. have you tried this ?
10923679 7-Aug-14 7:22am    
no i havent tired that..
i dont have much ide abt

can u have with Selected Index Changed ?

Thanks7872 7-Aug-14 8:01am    
If you don't have much idea about than you won't be able to understand the solution provided by members here. Its just waste of time for you and for all.
10923679 8-Aug-14 0:35am    
but.. members are helping me a lot... and m learning here.
anyway thank your time .
10923679 7-Aug-14 7:24am    
Actually i want to fill the new column of the table by dropbox value=2000 or 2001 to all rows which existing table.


about selected index changed event refer MSDN article:
MSDN-ListControl Selected Index Changed Event[^]

In that event, just update the database table using below sql query by passing the selected value of the dropdown list

Declare @year int
set @year = @dropdownvalue --pass your dropdown value here
update table1 set year=@year

hope this helps.
Share this answer
UPDATE table SET new column = '@year from Dropdown' where column like '%'

this will update all the rows of the recorded table..
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