Click here to Skip to main content
15,901,368 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
i have two date time picker named as follows;
dt_startweek and dt_endweek as two datetimepicker.

when i click the dt_startweek picker 21stdate in the dt_endweek picker five days 26th date to be displayed in the dt_endweek.

for that code as follows;

private void dt_startweek_ValueChanged(object sender, EventArgs e)
        DateTime dt = dt_startweek.Value;
        dt_endweek.Value = dt;
        DateTime startdate = dt_startweek.Value;
        DateTime enddate = dt_endweek.Value;
the above code is working fine no problem.

then i have one button called load when i click the load button that datepicker date 5 days to be saved in the data base.

for that saving the date into the can i write code to save in the database.

help me.

Date base design as follows;

Fac_sch_date Date time (Data type)

output i want in the table as follows;


the above date to be saved in the data base when i click the load button.

what date i choose in the dt_startweek that date to be saved in the database.

please help me.
Updated 29-Jan-13 3:16am
[no name] 29-Jan-13 9:27am    
Dnt forget to say thanx who help u buddy.. its easy to copy n paste soln which u got frm smeone else...
[no name] 29-Jan-13 11:29am    
ok to save the date time picker date in database when i click the button.

please help me.
Rgds & thanks

1 solution

why not use the loop, when you want to do event Insert into database,
like this :
protected void Button1_Click(object sender, EventArgs e)
            var dtime = dt_startweek.Value;
            var data = new ArrayList();
            for (var i = 0; i < 6; i++)
                var xx = dtime.AddDays(i);
                // do for insert into database in here,can too..
// OR
//Your first capacity in each variable, then enter one of the database into your
            var x1 = data[0];// date 21 from arraylist index [0]
            var x2 = data[1];// date 22
            var x3 = data[2];// date 23
            var x4 = data[3];// date 24
            var x5 = data[4];// date 25
            var x6 = data[5];// date 26

  // OR Like This

            var d1 = dtime;
            var d2 = dtime.AddDays(1);
            var d3 = dtime.AddDays(2);
            var d4 = dtime.AddDays(3);
            var d5 = dtime.AddDays(4);
            var d6 = dtime.AddDays(5);


This parable is only sample code it .. just as a prefix to pave the way forward her your logic, associated with your coding
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