Jawab daysofweek

  • 30 Mei 2012 7:54
     
     

    Hy,

    i have a dropdown list with checkboxes, my items are weekdays names.

    the week day's can be in: dutch, french, ..

    with every course that is entered, i want to get the weekday's numbers.

    so that the booking process for a classroom can begin.

    i can check for every language with day it is.

    but is it possible to do it like , when recieving the day  number of a datetim.now

    "datetime td = new datetime.now;

    (int)td.dayofweek"

    regards

Semua Balasan

  • 30 Mei 2012 8:21
    Penjawab Pertanyaan
     
     Saran Jawaban

    Hello,

    Yes this line should work. Have you an error?


    Best regards, Christopher.
    Blog | Mail
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

  • 30 Mei 2012 8:39
     
      Memiliki Kode

    I confirm this should work.

    More information here:

    With a sample code:

    DateTime dt = new DateTime(2003, 5, 1);
    Console.WriteLine("Is Thursday the day of the week for {0:d}?: {1}", dt, dt.DayOfWeek == DayOfWeek.Thursday);
    Console.WriteLine("The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek);

    Output:

    • Is Thursday the day of the week for 5/1/2003?: True
    • The day of the week for 5/1/2003 is Thursday.

    Cordialement/Regards,

    Ludovic Caffin
    .NET/SharePoint Consultant for A3IS.

  • 30 Mei 2012 8:39
     
     

    the line for recieving the day number works fine :)

    i was thinking, if i can recieve a day number from my dropdown list: "day name"

    so that i can place my day name from my dropdown into a datetime object without a date, for recieving my day number

  • 30 Mei 2012 8:52
     
     Jawab

    Each item of your dropdown list has a text and a value.

    If you set for each day item, the same value this day has in the DayOfWeek enumeration, then you will be able to make the comparison.


    Cordialement/Regards,

    Ludovic Caffin
    .NET/SharePoint Consultant for A3IS.

    • Ditandai sebagai Jawaban oleh kim.vlas 30 Mei 2012 9:36
    •  
  • 30 Mei 2012 9:36
     
     

    thanks

    this is only possible when i create a item.

    when the item has be created, and i asked for the value inside: ";#Monday;#Tuesday".

    or is it olso possible when the item has already be created?

  • 30 Mei 2012 9:51
     
     

    Yes it is always possible to modify a list item value after it has been created:

    ListItem.Value Property - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listitem.value.aspx


    Cordialement/Regards,

    Ludovic Caffin
    .NET/SharePoint Consultant for A3IS.