Click here to Skip to main content
15,886,067 members

Validate the date is preceding to the date

Member 8054539 asked:

Open original thread
C#
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;
                            }
                        }


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


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

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.
Tags: C#

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900