Click here to Skip to main content
15,884,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 23-Apr-13 22:42pm
v2

1 solution

To format the date I think the following will help

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


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

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


hope this helps
 
Share this answer
 
v2

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



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