0

Hello,
(C# AND ASP.NET)
For a particular employee i have his details stored in the database. These details also contain joining date which is stored in the database in the format yyyy-mm-dd.

In the front end i have 3 dropdown lists one for DD another for MM and the third one for YYYY. All these 3 ddl's are filled up by appropriate values on load.

When i wish to see a particular record of the employee i should get to see the joining date of employee in its respective ddl selected.

For Ex:

In my database say date is 2000-01-01 for employee No 1.
so when i select to see the details of employee No 1.. the joining date should be displayed in my front end as:

In my Day ddl i should 01 selected
in my Month ddl i should 01 selected
and my Year ddl i should get 2000 selected.

Please anyone can help me out...??

Awating reply...

cya,
Rohan

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by finito
0

on page load you are filling all the DROPdownlist
that is correct next you need to check the Employee date of joining
which u can get it from the database and store in string. use substring to
divide year, month and date and bind the DropDown accordingly by using

// Basic Part for Loading DropDown..
        for (int i = 1961; i < DateTime.Now.Year; i++)
        {
            DropDownList1.Items.Add(i.ToString());
        }

        // Next you wanna load 2008

        DropDownList1.Text = "2008"; // This would be the value from the DataBase

There are other ways to do it..!
hope that helps.

0

the other way is, you can use Year(yourcolumnname), Month(yourcolumnname), Day(yourcolumnname) functions of SQL server and bind your drop down accordingly..

hope it will help you...

========================================================================================

Hello,
(C# AND ASP.NET)
For a particular employee i have his details stored in the database. These details also contain joining date which is stored in the database in the format yyyy-mm-dd.

In the front end i have 3 dropdown lists one for DD another for MM and the third one for YYYY. All these 3 ddl's are filled up by appropriate values on load.

When i wish to see a particular record of the employee i should get to see the joining date of employee in its respective ddl selected.

For Ex:

In my database say date is 2000-01-01 for employee No 1.
so when i select to see the details of employee No 1.. the joining date should be displayed in my front end as:

In my Day ddl i should 01 selected
in my Month ddl i should 01 selected
and my Year ddl i should get 2000 selected.

Please anyone can help me out...??

Awating reply...

cya,
Rohan

0
DateTime DbDate = new DateTime()

DbDate.Day;
DbDate.Month;
DabDate.Year;

Once you declare DbDate just use .Day, .Month, or .Year to get what you want.

Edited by finito: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.