protected void State_datagrid_RowDataBound(object sender, GridViewRowEventArgs e) { DataTable dt = new DataTable(); DBConnection obj = new DBConnection(); if (e.Row.RowIndex != -1) { try { int Vid = Convert.ToInt32(State_datagrid.DataKeys[e.Row.RowIndex][0]); dt = VADBCommander.PropertyAvailDatesList(Vid.ToString(), DateTime.Today.ToString()); HtmlGenericControl div = (HtmlGenericControl)e.Row.FindControl("divCalendar"); if (dt.Rows.Count > 0) { div.Visible = true; } else { div.Visible = false; } //show reviews button..select * where propertyID match HtmlGenericControl divReview = (HtmlGenericControl)e.Row.FindControl("divWrite"); dt = obj.spSelectCommentExist(Vid); if (dt.Rows.Count > 0) { divReview.Visible = true; } else { divReview.Visible = false; } //show amenities Label lblAmenities = (Label)e.Row.FindControl("lblAmenities"); dt = VADBCommander.AmenitiesByProperty(Vid.ToString()); List <string> vList = new List <string>(); List <string> vList2 = new List <string>(); vList2.Add("Lake Front"); vList2.Add("River Front"); vList2.Add("Pet Friendly"); vList2.Add("Private Swimming Pool"); vList2.Add("Shared Swimming Pool"); vList2.Add("BBQ Grill"); vList2.Add("Internet Access"); vList2.Add("Children Not Allowed"); vList2.Add("Hot Tub"); vList2.Add("Wood Fireplace"); vList2.Add("Gas Fireplace"); vList2.Add("Shared Jacuzzi"); vList2.Add("Jacuzzi - Outside"); vList2.Add("Ski In Ski Out"); vList2.Add("Seaside"); vList2.Add("Beach Front"); for (int x = 0; x < dt.Rows.Count; x++) { if (vList2.Contains(dt.Rows[x]["Amenity"].ToString())) { string amn = dt.Rows[x]["Amenity"].ToString().Trim(); if (amn == "Seaside" || amn == "Lake Front" || amn == "River Front" || amn == "Beach Front" || amn == "Ski In Ski Out" || amn == "Pet Friendly" || amn == "Private Swimming Pool" || amn == "Wood Fireplace" || amn == "Internet Access") { if (lblAmenities.Text == "") { lblAmenities.Text += dt.Rows[x]["Amenity"].ToString(); } else { lblAmenities.Text += ", " + dt.Rows[x]["Amenity"].ToString(); } } } } HtmlGenericControl li = (HtmlGenericControl)e.Row.FindControl("liAmenity"); if (lblAmenities.Text == "") { li.Visible = false; } //long descriptions Label lblDesc = (Label)e.Row.FindControl("lblDesc"); if (lblDesc != null) { if (lblDesc.Text.Length > 320) { //int x = 130; //while (lblDesc.Text.Substring(x, 1) != " ") //{ // x++; //} //lblDesc.Text = lblDesc.Text.Remove(x); //lblDesc.Text += "...<a href=\""; //string temp = CommonFunctions.GetSiteAddress() + "/" + country + // "/" + stateprovince + "/" + city + "/" + Vid + "/default.aspx\">more</a>"; //temp = temp.ToLower(); //temp = temp.Replace(' ', '_'); //lblDesc.Text += temp; lblDesc.Text = lblDesc.Text.Remove(157); lblDesc.Text += "..."; } } dt = VADBCommander.PropertyInd(Vid.ToString()); Label lblPic = (Label)e.Row.FindControl("lblPicName"); if ((lblPic != null) && (dt.Rows.Count > 0)) { lblPic.Text = dt.Rows[0]["name2"].ToString(); //if (lblPic.Text.Length > 30) // lblPic.Text = lblPic.Text.Remove(30); } //Label lblPN = (Label)e.Row.FindControl("lblPNRates"); //if (lblPN != null) //{ // if (dt.Rows[0]["minNightRate"].ToString() != "") // { // lblPN.Text = dt.Rows[0]["minNightRate"].ToString() + "-" + dt.Rows[0]["HiNightRate"].ToString() + " " + // dt.Rows[0]["minRateCurrency"].ToString() + " Per Night"; // } //} Label lblPN = (Label)e.Row.FindControl("lblPNRates"); Label lblPNCurrency = (Label)e.Row.FindControl("lblPNRatesCurrency"); Label lblPNBasis = (Label)e.Row.FindControl("lblPNRatesBasis"); //Label lblPNMinimumNights = (Label)e.Row.FindControl("lblMinimumNights"); if (lblPN != null) { if (dt.Rows[0]["minNightRate"].ToString() != "") { lblPN.Text = dt.Rows[0]["minNightRate"].ToString() + "-" + dt.Rows[0]["HiNightRate"].ToString(); lblPNCurrency.Text = dt.Rows[0]["minRateCurrency"].ToString(); lblPNBasis.Text = " Per Night"; //lblPNMinimumNights.Text = ""; //lblPNMinimumNights.Text = " Night Minimum"; } //if (dt.Rows[0]["minNightRate"].ToString() != "") //{ // lblPN.Text = dt.Rows[0]["minNightRate"].ToString() + "-" + dt.Rows[0]["HiNightRate"].ToString() + " " + // dt.Rows[0]["minRateCurrency"].ToString() + " Per Night"; //} } } catch (Exception ex) { lblInfo22.Text = ex.Message; } finally { obj.CloseConnection(); } } }