验证日期在日期之前 [英] Validate the date is preceding to the date

查看:69
本文介绍了验证日期在日期之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Repeater rptdates = new Repeater();
                rptdates = (Repeater)rpt1.Items[e.Item.ItemIndex].FindControl("rptLevel2");
                string BatchDates="";
                string dates = "";

                  DropDownList ddllist = new DropDownList();
                LinkButton LnkLevel2 = new LinkButton();
                int flag = 0;
                string PKGMinorCode = "";

                for (int i = 0; i < rptdates.Items.Count; i++)
                {
                    ddllist = (DropDownList)rptdates.Items[i].FindControl("ddlDate");
                    BatchDates = BatchDates + ddllist.SelectedValue.ToString().Trim() + "+";
                    dates += ddllist.SelectedItem.Text.ToString() + ",";

                    LnkLevel2 = (LinkButton)rptdates.Items[i].FindControl("lnkLevel2");
                    PKGMinorCode += LnkLevel2.CommandArgument.ToString().Trim() + ",";
                }

                string[] Coursecheck;
                datecheck = dates.Split(',');
                Coursecheck = PKGMinorCode.Split(',');
                int len = datecheck.Length;
                for (int z = 0; z < len-1; z++)
                {
                    for (int j = z + 1; j < len-1 ; j++)
                    {
                   
                        //PSCRB Date must be preceding to  AFF Date
                        if (Coursecheck[z] == "RPSCRB" && Coursecheck[j] == "R-AFF")
                        {
                            if (datecheck[z] != datecheck[j])
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "Invalid date", "alert('RPSCRB and R-AFF Dates must not be the same date')", true);
                                return;
                            }
                        }




运行模式下的
我选择时间消息显示的PSCRB日期之后的AFF日期

PSCRB日期必须在AFF日期之前



从上面的代码我该怎么办?





AFF日期在下拉列表中的日期如下;



2013年5月16日



PSCRB下拉列表中的日期如下;



2013年5月19日







in run mode i select the AFF Date after than PSCRB Date that time message shows
PSCRB Date must be preceding to AFF Date

From my above code how can i do?


AFF Date in dropdownlist as follows;

16 May 2013

PSCRB Date in Dropdownlist as follows;

19 May 2013


if (datecheck[z] != datecheck[j])



在上面这行怎样才能检查PSCRB日期必须在AFF日期之前





输出我想要的跟随;



AFF日期在下拉列表中的日期如下;



2013年5月15日


PSCRB下拉列表中的日期如下;



2013年5月14日





请帮帮我



问候,

Narasiman P.


in the above line how can i check PSCRB Date must be preceding to AFF Date


Output i want as follows;

AFF Date in dropdownlist as follows;

15 May 2013

PSCRB Date in Dropdownlist as follows;

14 May 2013


Please help me

Regards,
Narasiman P.

推荐答案

要格式化日期,我认为以下内容将有所帮助



To format the date I think the following will help

ddllist.SelectedValue.ToString("dd MMMM yyyy")





并检查日期是否在前我认为您可以执行以下操作





and to check if date is preceding i think you can do the following

if (((DateTime)datecheck[z]).Date < ((DateTime)datecheck[j]).Date)





希望这有帮助



hope this helps


这篇关于验证日期在日期之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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