如何使用dropdownlist控件显示日期? [英] How to use dropdownlist control to show date?

查看:79
本文介绍了如何使用dropdownlist控件显示日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有沙龙的预约管理系统我必须在今天到下一个60天的下拉列表中显示日期我必须显示从09:00到09:30的时间,间隔为30分钟当用户登录时在用户中只能看到可用于约会的日期。当用户从第一个下拉列表中选择可用日期然后在时间下拉列表中他应该只看到可用于预约约会的时间或时间我必须从数据库中检查这个时间用户选择他想要的服务然后相应的时间存储在数据库中。



服务有持续时间。持续时间因服务而异。如您所知,沙龙为不同的服务所花费的时间。持续时间存储在数据库中。然后需要在所选时间内添加持续时间,并且必须检查该时隙是否可用,如果不是他必须选择另一个时间或另一个日期。我的数据库表名是约会。

I have an appointment management system for Salon I have to show dates in dropdownlist from today to next 60 days And I have to show times from 09:00 Am to 09:30 PM with the interval of 30 mins When the user logs in the user can only see dates which are available for the appointment. When the user selects the available date from the first dropdownlist then in the time dropdownlist he should only see the time or the time slots which are available to book the appointment I have to check this from the database The user selects services which he wants then accordingly the time is stored in the database.

The services has time duration. And the duration varies to services. As you know the time taken in Salon for different services. The duration is stored in the database. And then time duration needs to be added with the selected time and it has to check whether that time slot is available or not if not than either he has to select another time or another date. My database table name is Appointments.

推荐答案

那你究竟需要什么?

整个代码?

您尝试了什么?

请按照以下步骤操作: -

仅使用具有日期的数据表和其他具有时间的数据绑定下拉列表/>
在选定的Index Changed事件上写下你的逻辑。



这样你可以处理日期: -

So What Exactly you need?
A whole code?
What you have tried?
Follow this:-
Bind dropdown simply with a datatable that will have dates and other one with time
On selected Index Changed event write your logics.

This way you can handle dates:-
var dtDate=new DataTable();

dtDate.Columns.Add("AppointmentDate",typeof(string));

for (var day = 0; day < 59; day++)
 {
   var drRow = dtDate.NewRow();
   drRow["AppointmentDate"] =  DateTime.Now.AddDays(day).ToString("MM/dd/yyyy");
   dtDate.Rows.Add(drRow);
 }


这是我发现显示日期的最简单方法。



This is the simplest way I have found to display the dates.

protected void Page_Load(object sender, EventArgs e)
   {
       DropDownList1.Items.Add(DateTime.Now.ToShortDateString());
       for (int i = 1; i <= 60; i++)
       {
           DropDownList1.Items.Add(DateTime.Now.AddDays(i).ToShortDateString());
       }
   }


这篇关于如何使用dropdownlist控件显示日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆