Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            int i = 0;
            int count = DataList1.Items.Count;            
            DateTime startime;
            if (e.Item.ItemType == ListItemType.AlternatingItem | e.Item.ItemType == ListItemType.Item)
            {               
                Label days = (Label)e.Item.FindControl("LblDate");
                ((Label)e.Item.FindControl("LblDays")).Text = Convert.ToDateTime(days.Text).DayOfWeek.ToString();
                Label s_Time = (Label)e.Item.FindControl("LblStart");
                if (s_Time.Text != "")
                {
                    startime = Convert.ToDateTime(s_Time.Text);
                    Label E_Time = (Label)e.Item.FindControl("LblEnd");
                    DateTime endtime = Convert.ToDateTime(E_Time.Text);
                    DateTime current = startime;
                    Label T_Slot = (Label)e.Item.FindControl("LblSlot");
                    int Slot = Convert.ToInt32(T_Slot.Text);
                    Table tab = e.Item.FindControl("Table2") as Table;
                    int j = 0;
                    while (current <= endtime)
                    {
                        TableRow newRow = new TableRow();
                        TableCell newCell = new TableCell();
                        LinkButton lnkSLot = new LinkButton();                       
                        lnkSLot.ID = Convert.ToDateTime(days.Text).DayOfWeek + "_" + current.ToString("hh:mm tt");
                        lnkSLot.Text = current.ToString("hh:mm tt");
                        current = current.AddMinutes(Slot);
                        lnkSLot.Click += new EventHandler(lnkSLot_Click);
                        newCell.Controls.Add(lnkSLot);
                        newRow.Controls.Add(newCell);
                        tab.Controls.Add(newRow);
                        j++;
                    }
                    i++;
                }
                else
                {
                    Table tab = e.Item.FindControl("Table2") as Table;
                    Label lbl = new Label();
                    lbl.ID = days.ToString();
                    lbl.Text = "No Slot available ";
                    TableRow newRow = new TableRow();
                    TableCell newCell = new TableCell();
                    newCell.Controls.Add(lbl);
                    newRow.Controls.Add(newCell);
                    tab.Controls.Add(newRow);
                }
            }
 
        }
        void lnkSLot_Click(object sender, EventArgs e)
        {
            //throw new NotImplementedException();
            LinkButton lnk = sender as LinkButton;
            Response.Write(lnk.ID);
        }
Posted 26-Apr-13 23:09pm
Edited 27-Apr-13 1:05am
(no name)498.5K
v2

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

  Print Answers RSS
0 OriginalGriff 8,149
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 27 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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