private void btnShow_Click(object sender, RoutedEventArgs e) { BuyerValidations buval = new BuyerValidations(); WrapPanel wp = new WrapPanel(); Border myBorder1 = new Border(); if (onlyonce == 0) { onlyonce++; // border for stackpanel myBorder1.Background = Brushes.Blue; myBorder1.BorderBrush = Brushes.Orange; myBorder1.BorderThickness = new Thickness(1); // fetching all the property data from DB List <Property> propertyList = new List <Property>(); propertyList = buval.showProperties(); foreach (var k in propertyList) { StackPanel StackOFDetails = new StackPanel(); // Intializing the UI Controls... Button btn = new Button(); Label lblPropname = new Label(); Label lblType = new Label(); Label lblPropOption = new Label(); Label lblPropDescription = new Label(); Label lblAddress = new Label(); Label lblPrice = new Label(); Label lblIntialdeposit = new Label(); Label lblLandMArk = new Label(); // Mapping the Property data with UI controls... int propId = k.PropertyId; lblPropname.Content = "Name: " + k.PropertyName; lblType.Content = "Type: " + k.PropertyType; lblPropOption.Content = "Option :" + k.PropertyOption; lblPropDescription.Content = "Description :" + k.Description; lblAddress.Content = "Address :" + k.Address; lblPrice.Content = "Price: " + k.PriceRange; lblIntialdeposit.Content = "Intial Deposit: " + k.InitialDeposit; lblLandMArk.Content = "LandMark:" + k.Landmark; btn.Content = "AddToCart"; // Appending All the UI Controls to stackpanel StackOFDetails.Children.Add(lblPropname); StackOFDetails.Children.Add(lblType); StackOFDetails.Children.Add(lblPropOption); StackOFDetails.Children.Add(lblPrice); StackOFDetails.Children.Add(lblIntialdeposit); StackOFDetails.Children.Add(lblLandMArk); StackOFDetails.Children.Add(lblAddress); StackOFDetails.Children.Add(lblPropDescription); StackOFDetails.Children.Add(btn); wp.Children.Add(StackOFDetails); // ConfirmCart method will be called and name will be passed to same method... btn.Click += (s, RoutedEventArgs) => { ConfirmCart(sender, e, propId); }; } // Adding stackpanel to the WrapPanel... MyWrapPanel.Children.Add(wp); MyWrapPanel.Children.Add(myBorder1); } else { MessageBox.Show("We have listed all the data avialable....!"); } }
/// <summary> /// Load Controls on OnInit event /// </summary> /// <param name="e"></param> override protected void OnInit(EventArgs e) { BuyerValidations buyerValidationObj = new BuyerValidations(); List <Property> propertyList = new List <Property>(); propertyList = buyerValidationObj.showProperties(state, city); if (propertyList == null) { Response.Write("<script>alert('There are no properties to be displayed');</script>"); } foreach (var k in propertyList) { string imgpath = @"Images\home_back.jpeg"; // Intializing the UI Controls... Label lblPropname = new Label { CssClass = "space" }; Label lblType = new Label { CssClass = "space" }; Label lblPropOption = new Label { CssClass = "space" }; Label lblPropDescription = new Label(); Label lblAddress = new Label(); Label lblPrice = new Label(); Label lblIntialdeposit = new Label(); Label lblLandMArk = new Label(); //Create Group Container Div HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "form-group"); // dynamic image System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image(); img.ImageUrl = imgpath; // Mapping the Property data with UI controls... lblPropname.Text = k.PropertyName; lblType.Text = "Type : " + k.PropertyType + " "; lblPropOption.Text = "Option : " + k.PropertyOption + " "; // lblPropDescription.Text = "Description : \t" + k.Description; lblAddress.Text = "Address : " + k.Address + " "; lblPrice.Text = "Price : " + k.PriceRange + " "; lblIntialdeposit.Text = "Intial Deposit : " + k.InitialDeposit + " "; lblLandMArk.Text = "LandMark : " + k.Landmark + " "; // Appending All the UI Controls to stackpanel div.Controls.Add(lblPropname); div.Controls.Add(img); div.Controls.Add(lblType); div.Controls.Add(lblPropOption); div.Controls.Add(lblPrice); div.Controls.Add(lblIntialdeposit); div.Controls.Add(lblLandMArk); div.Controls.Add(lblAddress); div.Controls.Add(lblPropDescription); //// label for type //div.Controls.Add(new Label() //{ // Text = "Type :" + k.PropertyType, // CssClass = "col-md-2 control-label" //}); //button.. string propertyId = k.PropertyId.ToString(); var btnAddcart = new Button { ID = "btnClick" + propertyId, Text = "Add To Cart", // CssClass = "col-md-2 btn btn-info" }; btnAddcart.Click += (s, RoutedEventArgs) => { ConfirmCart(s, e, propertyId); }; // GetDataItem owner details.. var btnOwnerDetails = new Button { Text = "Get Owner Details", // CssClass = "col-md-2 btn btn-info" }; // Adding all the childs to div bodydiv.Controls.Add(div); bodydiv.Controls.Add(btnAddcart); bodydiv.Controls.Add(btnOwnerDetails); // After adding all the childs.. bodydiv.Controls.Add(new LiteralControl("<br /><br/>")); } }
/// <summary> /// Load Controls on OnInit event /// </summary> /// <param name="e"></param> override protected void OnInit(EventArgs e) { BuyerValidations buyerValidationObj = new BuyerValidations(); List<Property> propertyList = new List<Property>(); if (ck == false) propertyList = buyerValidationObj.showProperties(state, city); else if(ck==true) propertyList = buyerValidationObj.GetPropertiesByPrice(min, max); else if (first == false) { HttpCookie reqCookies = Request.Cookies["sortInfo"]; if (reqCookies != null) { state = reqCookies["State"].ToString(); city = reqCookies["City"].ToString(); } propertyList = buyerValidationObj.showProperties(state, city); first = true; } if (propertyList == null && ck != null) Response.Write("<script>alert('There are no properties to be displayed');</script>"); int f = 0; foreach (var k in propertyList) { f++; string imgpath = @"Images\"+f+".jpeg"; // Intializing the UI Controls... Label lblPropname = new Label { CssClass = "space", ForeColor = System.Drawing.Color.DarkBlue }; Label lblType = new Label { CssClass = "space" }; Label lblPropOption = new Label { CssClass = "space" }; Label lblPropDescription = new Label(); Label lblAddress = new Label(); Label lblPrice = new Label(); Label lblIntialdeposit = new Label(); Label lblLandMArk = new Label(); //Create Group Container Div HtmlGenericControl div = new HtmlGenericControl("div"); div.Attributes.Add("class", "form-group"); // dynamic image System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image(); img.ImageUrl = imgpath; // styles lblPropname.Style.Add("font-size", "25px"); lblPropname.Style.Add("font-family", "Century Gothic"); lblPropname.Style.Add("font-weight", "bold"); lblType.Style.Add("font-family", "Century Gothic"); lblType.Style.Add("font-weight", "bold"); lblPropOption.Style.Add("font-family", "Century Gothic"); lblPropOption.Style.Add("font-weight", "bold"); lblPropDescription.Style.Add("font-family", "Century Gothic"); lblPropDescription.Style.Add("font-weight", "bold"); lblAddress.Style.Add("font-family", "Century Gothic"); lblAddress.Style.Add("font-weight", "bold"); lblPrice.Style.Add("font-family", "Century Gothic"); lblPrice.Style.Add("font-weight", "bold"); lblIntialdeposit.Style.Add("font-family", "Century Gothic"); lblIntialdeposit.Style.Add("font-weight", "bold"); lblLandMArk.Style.Add("font-family", "Century Gothic"); lblLandMArk.Style.Add("font-weight", "bold"); // Mapping the Property data with UI controls... lblPropname.Text = k.PropertyName; lblType.Text = "Type : " + k.PropertyType + " || "; lblPropOption.Text = "Option : " + k.PropertyOption + " || "; // lblPropDescription.Text = "Description : \t" + k.Description; lblAddress.Text = "Address : " + k.Address + " "; lblPrice.Text = "Price : " + (int)k.PriceRange + " || "; lblIntialdeposit.Text = "Intial Deposit : " + (int)k.InitialDeposit + " || "; lblLandMArk.Text = "LandMark : " + k.Landmark + " || "; // Appending All the UI Controls to stackpanel div.Controls.Add(new LiteralControl("<br/>")); div.Controls.Add(lblPropname); div.Controls.Add(new LiteralControl("<br/><br/>")); div.Controls.Add(img); div.Controls.Add(lblType); div.Controls.Add(lblPropOption); div.Controls.Add(lblPrice); div.Controls.Add(lblIntialdeposit); div.Controls.Add(lblLandMArk); div.Controls.Add(lblAddress); div.Controls.Add(lblPropDescription); //// label for type //div.Controls.Add(new Label() //{ // Text = "Type :" + k.PropertyType, // CssClass = "col-md-2 control-label" //}); //button.. string propertyId = k.PropertyId.ToString(); var btnAddcart = new Button { ID = "btnClick" + propertyId, Text = "Add To Cart", CssClass = "btn btn-info" }; btnAddcart.Click += (s, RoutedEventArgs) => { ConfirmCart(s, e, propertyId); }; // GetDataItem owner details.. var btnOwnerDetails = new LinkButton { Text = "Get Owner Details", CssClass = "btn btn-info" }; // button styles btnAddcart.Style.Add("font-family", "Century Gothic"); btnOwnerDetails.Style.Add("font-family", "Century Gothic"); btnOwnerDetails.Click += (s, RoutedEventArgs) => { GetContactDetails(s, e, propertyId); }; // Adding all the childs to div bodydiv.Controls.Add(div); bodydiv.Controls.Add(btnAddcart); bodydiv.Controls.Add(new LiteralControl(" ")); bodydiv.Controls.Add(btnOwnerDetails); // After adding all the childs.. bodydiv.Controls.Add(new LiteralControl("<br/><br/>")); } }