public void DataBindTemplate(object sender, EventArgs e) { PlaceHolder templatePlaceHolder = sender as PlaceHolder; ListBoxItemTemlateContainer container = templatePlaceHolder.NamingContainer as ListBoxItemTemlateContainer; ListBoxItem item = (ListBoxItem)container.Parent; Literal title = new Literal(); title.Text = "<div title=\"" + DataBinder.Eval(item.DataItem, "CompanyName").ToString() + " from " + DataBinder.Eval(item.DataItem, "City").ToString() + "\">"; Literal supplierIDText = new Literal(); supplierIDText.Text = "<div class=\"item c1\">" + DataBinder.Eval(item.DataItem, "SupplierID").ToString() + "</div>"; Literal companyNameText = new Literal(); companyNameText.Text = "<div class=\"item c2\">" + DataBinder.Eval(item.DataItem, "CompanyName").ToString() + "</div>"; Literal cityText = new Literal(); cityText.Text = " <div class=\"item c3\">" + DataBinder.Eval(item.DataItem, "City").ToString() + "</div>"; Literal endTitle = new Literal(); endTitle.Text = "</div>"; templatePlaceHolder.Controls.Add(title); templatePlaceHolder.Controls.Add(supplierIDText); templatePlaceHolder.Controls.Add(companyNameText); templatePlaceHolder.Controls.Add(cityText); templatePlaceHolder.Controls.Add(endTitle); }
public void DataBindTemplate(object sender, EventArgs e) { PlaceHolder templatePlaceHolder = sender as PlaceHolder; ListBoxItemTemlateContainer container = templatePlaceHolder.NamingContainer as ListBoxItemTemlateContainer; ListBoxItem item = (ListBoxItem)container.Parent; Literal companyNameText = new Literal(); companyNameText.Text = "<span class=\"template-name\">" + DataBinder.Eval(item.DataItem, "CompanyName").ToString() + "</span>"; Literal countryText1 = new Literal(); countryText1.Text = " / <span class=\"template-country\">" + DataBinder.Eval(item.DataItem, "Country").ToString() + " "; Image flag = new Image(); flag.ImageUrl = GetCountryFlag(DataBinder.Eval(item.DataItem, "Country").ToString()); Literal countryText2 = new Literal(); countryText2.Text = "</span>"; templatePlaceHolder.Controls.Add(companyNameText); templatePlaceHolder.Controls.Add(countryText1); templatePlaceHolder.Controls.Add(flag); templatePlaceHolder.Controls.Add(countryText2); }
public void DataBindTemplate(object sender, EventArgs e) { PlaceHolder templatePlaceHolder = sender as PlaceHolder; ListBoxItemTemlateContainer container = templatePlaceHolder.NamingContainer as ListBoxItemTemlateContainer; ListBoxItem item = (ListBoxItem)container.Parent; Literal item11 = new Literal(); item11.Text = "<div class=\"item c1\">"; Image img = new Image(); img.ImageUrl = "~/Grid/resources/images/products/" + DataBinder.Eval(item.DataItem, "Image").ToString(); Literal item12 = new Literal(); item12.Text = "</div>"; Literal item21 = new Literal(); item21.Text = "<div class=\"item c2\">"; Literal item22 = new Literal(); item22.Text = DataBinder.Eval(item.DataItem, "ProductName").ToString(); Literal item23 = new Literal(); item23.Text = "</div>"; Literal item31 = new Literal(); item31.Text = "<div class=\"item c3\">"; Literal item32 = new Literal(); //item32.Text = string.Format("{0:C2}", DataBinder.Eval(item.DataItem, "UnitPrice").ToString()); item32.Text = Convert.ToDouble(DataBinder.Eval(item.DataItem, "UnitPrice").ToString()).ToString("$#,##0.00;($#,##0.00);Zero"); Literal item33 = new Literal(); item33.Text = "</div>"; templatePlaceHolder.Controls.Add(item11); templatePlaceHolder.Controls.Add(img); templatePlaceHolder.Controls.Add(item12); templatePlaceHolder.Controls.Add(item21); templatePlaceHolder.Controls.Add(item22); templatePlaceHolder.Controls.Add(item23); templatePlaceHolder.Controls.Add(item31); templatePlaceHolder.Controls.Add(item32); templatePlaceHolder.Controls.Add(item33); }
public void DataBindTemplate(object sender, EventArgs e) { PlaceHolder templatePlaceHolder = sender as PlaceHolder; ListBoxItemTemlateContainer container = templatePlaceHolder.NamingContainer as ListBoxItemTemlateContainer; ListBoxItem item = (ListBoxItem)container.Parent; Literal itemText = new Literal(); itemText.Text = "#" + DataBinder.Eval(item.DataItem, "OrderID").ToString(); templatePlaceHolder.Controls.Clear(); templatePlaceHolder.Controls.Add(itemText); }
public void DataBindTemplate(object sender, EventArgs e) { PlaceHolder templatePlaceHolder = sender as PlaceHolder; ListBoxItemTemlateContainer container = templatePlaceHolder.NamingContainer as ListBoxItemTemlateContainer; ListBoxItem item = (ListBoxItem)container.Parent; Literal innerContainer = templatePlaceHolder.Controls[2] as Literal; innerContainer.Text = "<div class=\"label\">"; innerContainer.Text += "<img src='resources/images/products/" + DataBinder.Eval(item.DataItem, "ImageName").ToString() + "' alt='' />"; innerContainer.Text += DataBinder.Eval(item.DataItem, "ControlName").ToString(); innerContainer.Text += "</div>"; innerContainer.Text += "</div>"; }
public void DataBindTemplate(object sender, EventArgs e) { PlaceHolder templatePlaceHolder = sender as PlaceHolder; ListBoxItemTemlateContainer container = templatePlaceHolder.NamingContainer as ListBoxItemTemlateContainer; ListBoxItem item = (ListBoxItem)container.Parent; Literal containerTemplate = new Literal(); if (!isPostBack) { containerTemplate.Text = "<div class=\"item c1\">" + DataBinder.Eval(item.DataItem, "SupplierID").ToString() + "</div><div class=\"item c2\">" + DataBinder.Eval(item.DataItem, "CompanyName").ToString() + "</div><div class=\"item c3\">" + DataBinder.Eval(item.DataItem, "City").ToString() + "</div>"; } templatePlaceHolder.Controls.Add(containerTemplate); }
public void DataBindTemplate(object sender, EventArgs e) { PlaceHolder templatePlaceHolder = sender as PlaceHolder; ListBoxItemTemlateContainer container = templatePlaceHolder.NamingContainer as ListBoxItemTemlateContainer; ListBoxItem item = (ListBoxItem)container.Parent; Literal Container1 = item.FindControl("Container1") as Literal; Container1.Text = DataBinder.Eval(item.DataItem, "SupplierID").ToString(); Literal Container2 = item.FindControl("Container2") as Literal; Container2.Text = DataBinder.Eval(item.DataItem, "CompanyName").ToString(); Literal Container3 = item.FindControl("Container3") as Literal; Container3.Text = DataBinder.Eval(item.DataItem, "City").ToString(); }