Click here to Skip to main content
13,901,044 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
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


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.
Posted
Updated 23-Apr-13 22:42pm
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190306.1 | Last Updated 24 Apr 2013
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100