Ejemplo n.º 1
0
        protected void repeaterListRating_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (ListItemType.Header == e.Item.ItemType || ListItemType.Footer == e.Item.ItemType)
            {
                return;
            }//No data to specifically bind on header or footer

            System.Web.UI.WebControls.Label overallRating = (System.Web.UI.WebControls.Label)e.Item.FindControl("lblOverallRating");//Finds overallRating in specific list element

            if (null != overallRating)
            {
                overallRating.Text += RateMyPlaceDisplayUtilities.generateStars((int)(((DataRowView)e.Item.DataItem)["OverallRating"]));//Replaces the integer with out of 10 stars
            }


            System.Web.UI.WebControls.Label locationRating = (System.Web.UI.WebControls.Label)e.Item.FindControl("lblLocation");//Finds overallRating in specific list element

            if (null != locationRating)
            {
                locationRating.Text += RateMyPlaceDisplayUtilities.generateStars((DBNull.Value == ((DataRowView)e.Item.DataItem)["Location"])?0:(int)((DataRowView)e.Item.DataItem)["Location"]);//Replaces the integer with out of 10 stars
            }
        }//For each item in repeater when bound with datasource
Ejemplo n.º 2
0
        }//Errors if nothing to compare

        protected void tblCompare_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            string[] miles      = new string[] { "Average Campus Distance", "Campus Distance" };
            string[] checkboxes = new string[] { "Study Space", "Shuttle", "Wifi", "Furnished", "TV", "Trash Service", "Gym", "Parking", "Pets" };
            string[] currency   = new string[] { "Average Rent", "Average Utilities", "Average Parking Fee", "Average Pets Fee", "Average Misc Fees", "Rent", "Utilities", "Parking Fee", "Pets Fee", "Misc Fees" };
            string[] stars      = new string[] { "Overall Rating", "Average Noise Amount", "Average Safety", "Average Maintenance Quality", "Average Location Rating", "Overall Rating", "Noise Amount", "Safety", "Maintenance Quality", "Location Rating" };
            string[] sqFoot     = new string[] { "Average Square Footage", "Square Footage" };
            string[] texts      = new string[] { "Author", "Pros", "Cons" };
            string[] dates      = new string[] { "Lease Start Date", "Lease End Date" };
            //Arrays of which row headers are to be what format

            if (0 <= Array.IndexOf(texts, e.Item.Cells[0].Text))
            {
                for (int i = 1; e.Item.Cells.Count > i; i++)
                {
                    if ("&nbsp;" != e.Item.Cells[i].Text)
                    {
                        e.Item.Cells[i].Text = e.Item.Cells[i].Text;//Displays text
                    }//If not null
                    else
                    {
                        e.Item.Cells[i].Text = "Unspecified";
                    } //Default to unspecified
                }     //For each column after header column
            }         //If row is to be a name

            if (0 <= Array.IndexOf(dates, e.Item.Cells[0].Text))
            {
                for (int i = 1; e.Item.Cells.Count > i; i++)
                {
                    if ("&nbsp;" != e.Item.Cells[i].Text)
                    {
                        e.Item.Cells[i].Text = DateTime.Parse(e.Item.Cells[i].Text).Date.ToString("yyyy-MM-dd");//Displays datetime converted to date
                    }//If not null
                    else
                    {
                        e.Item.Cells[i].Text = "Unspecified";
                    } //Default to unspecified
                }     //For each column after header column
            }         //If row is to be a date

            if (0 <= Array.IndexOf(stars, e.Item.Cells[0].Text))
            {
                for (int i = 1; e.Item.Cells.Count > i; i++)
                {
                    if ("&nbsp;" != e.Item.Cells[i].Text)
                    {
                        e.Item.Cells[i].Text = RateMyPlaceDisplayUtilities.generateStars(int.Parse(e.Item.Cells[i].Text));//Converts int value to stars out of max
                    }//If not null
                    else
                    {
                        e.Item.Cells[i].Text = RateMyPlaceDisplayUtilities.generateStars(0);
                    } //Default to 0 stars
                }     //For each column after header column
            }         //If row is to be a stars

            if (0 <= Array.IndexOf(currency, e.Item.Cells[0].Text))
            {
                for (int i = 1; e.Item.Cells.Count > i; i++)
                {
                    if ("&nbsp;" != e.Item.Cells[i].Text)
                    {
                        e.Item.Cells[i].Text = string.Format("${0:0.00}", float.Parse(e.Item.Cells[i].Text));//Converts float value to currency
                    }//If not null
                    else
                    {
                        e.Item.Cells[i].Text = "$0.00";
                    } //Defaults to $0
                }     //For each column after header column
            }         //If row is to be a currency

            if (0 <= Array.IndexOf(miles, e.Item.Cells[0].Text))
            {
                for (int i = 1; e.Item.Cells.Count > i; i++)
                {
                    if ("&nbsp;" != e.Item.Cells[i].Text)
                    {
                        e.Item.Cells[i].Text += " mi.";//Converts float value to miles
                    }//If not null
                    else
                    {
                        e.Item.Cells[i].Text = "Unspecified";
                    } //Default to unspecified
                }     //For each column after header column
            }         //If row is to be miles

            if (0 <= Array.IndexOf(checkboxes, e.Item.Cells[0].Text))
            {
                for (int i = 1; e.Item.Cells.Count > i; i++)
                {
                    System.Web.UI.WebControls.CheckBox newCheckBox = new System.Web.UI.WebControls.CheckBox();
                    newCheckBox.Checked = ("1" == e.Item.Cells[i].Text);      //Sets checked value of checkbox based on integer text
                    newCheckBox.Attributes.Add("class", "checkbox");          //Adds checkbox css class
                    newCheckBox.Attributes.Add("onClick", "return false");    //Prevents checkbox from being used by users
                    e.Item.Cells[i].Text            = "";                     //Clears text from cell
                    e.Item.Cells[i].HorizontalAlign = HorizontalAlign.Center; //Centers checkbox in cell
                    e.Item.Cells[i].Controls.Add(newCheckBox);                //Adds checkbox to cell
                }//For each column after header column
            }//If row is to be a checkbox

            if (0 <= Array.IndexOf(sqFoot, e.Item.Cells[0].Text))
            {
                for (int i = 1; e.Item.Cells.Count > i; i++)
                {
                    if ("&nbsp;" != e.Item.Cells[i].Text)
                    {
                        e.Item.Cells[i].Text += " sq. ft.";//Converts float value to sq ft
                    }//If not null
                    else
                    {
                        e.Item.Cells[i].Text = "Unspecified";
                    } //Default to unspecified sq foot
                }     //For each column after header column
            }         //If row is to be square footage
        }             //Called for each row added to table