Html R./COD>而不是在循环中连接字符串。未经请求的建议:考虑使用CSS类而不是内联样式,并使用CSS在元素之间添加空间而不是行中断。您还可以考虑使用StringBuilder,而不是在循环中串联字符串。 SqlHey SQLView
R./COD>而不是在循环中连接字符串。未经请求的建议:考虑使用CSS类而不是内联样式,并使用CSS在元素之间添加空间而不是行中断。您还可以考虑使用Html R./COD>而不是在循环中连接字符串。未经请求的建议:考虑使用CSS类而不是内联样式,并使用CSS在元素之间添加空间而不是行中断。您还可以考虑使用StringBuilder,而不是在循环中串联字符串。 SqlHey SQLView,html,asp.net,Html,Asp.net,R./COD>而不是在循环中连接字符串。未经请求的建议:考虑使用CSS类而不是内联样式,并使用CSS在元素之间添加空间而不是行中断。您还可以考虑使用StringBuilder,而不是在循环中串联字符串。 SqlHey SQLViewProducts = new SqlHey(); DataSet DSViewProducts = new DataSet(); string Sheilta = "SELECT TblShop.
StringBuilder
,而不是在循环中串联字符串。
SqlHey SQLViewProducts = new SqlHey();
DataSet DSViewProducts = new DataSet();
string Sheilta = "SELECT TblShop.ItemName, TblShop.Price, TblShop.ShopType, TblShop.Image, TblShop.Description FROM TblShop;";
DSViewProducts = SQLViewProducts.chkData(Sheilta);
int I;
for (I = 0; I < DSViewProducts.Tables[0].Rows.Count; I++)
{
if (DSViewProducts.Tables[0].Rows.Count % 2 == 0)
{
if (I % 2 == 0)
CatalogProducts.InnerHtml += " <div class=\"row\"> <div style=\"position: relative\" class=\"col-lg-3 col-md-4 col-sm-6 col-xs-12 col-sm-push-1 animated bounceInLeft\"> <div class=\"hovereffect\"> <img class=\"img-responsive\" src= \".." + DSViewProducts.Tables[0].Rows[I][3].ToString() + "\"" + " alt=\"\"> <div class=\"overlay\"> <h2>Add to cart<span style=\"font-size: 0.65em\"></span> <asp:Button ID=\"Button1\" runat=\"server\" BackColor=\"Transparent\" BorderStyle=\"None\" ForeColor=\"Transparent\" Height=\"43px\" Style=Height=\"z-index: 99; left: 0px; position: absolute; top: 0px\" Text=\"a\" Width=\"87px\" /></h2> <p class=\"icon-links\">" + DSViewProducts.Tables[0].Rows[I][0].ToString() + "<br /> " + DSViewProducts.Tables[0].Rows[I][4].ToString() + " </p> </div> </div> </div>";
else CatalogProducts.InnerHtml += " <div style=\"position: relative\" class=\"col-lg-3 col-md-4 col-sm-6 col-xs-12 col-sm-push-1 animated bounceInLeft\"> <div class=\"hovereffect\"> <img class=\"img-responsive\" src= \".." + DSViewProducts.Tables[0].Rows[I][3].ToString() + "\"" + " alt=\"\"> <div class=\"overlay\"> <h2>Add to cart<span style=\"font-size: 0.65em\"></span> <asp:Button ID=\"Button1\" runat=\"server\" BackColor=\"Transparent\" BorderStyle=\"None\" ForeColor=\"Transparent\" Height=\"43px\" Style=\"z-index: 99; left: 0px; position: absolute; top: 0px\" Text=\"a\" Width=\"87px\" /></h2> <p class=\"icon-links\">" + DSViewProducts.Tables[0].Rows[I][0].ToString() + "<br /> " + DSViewProducts.Tables[0].Rows[I][4].ToString() + " </p> </div> </div> </div> </div> <br /> <br />";
}
if (DSViewProducts.Tables[0].Rows.Count % 2 != 0)
{
if (I + 1 == DSViewProducts.Tables[0].Rows.Count)
CatalogProducts.InnerHtml += " <div class=\"row\"> <div style=\"position: relative\" class=\"col-lg-3 col-md-4 col-sm-6 col-xs-12 col-sm-push-1 animated bounceInLeft\"> <div class=\"hovereffect\"> <img class=\"img-responsive\" src= \".." + DSViewProducts.Tables[0].Rows[I][3].ToString() + "\"" + " alt=\"\"> <div class=\"overlay\"> <h2>Add to cart<span style=\"font-size: 0.65em\"></span> <asp:Button ID=\"Button1\" runat=\"server\" BackColor=\"Transparent\" BorderStyle=\"None\" ForeColor=\"Transparent\" Height=\"43px\" Style=Height=\"z-index: 99; left: 0px; position: absolute; top: 0px\" Text=\"a\" Width=\"87px\" /></h2> <p class=\"icon-links\">" + DSViewProducts.Tables[0].Rows[I][0].ToString() + "<br /> " + DSViewProducts.Tables[0].Rows[I][4].ToString() + " </p> </div> </div> </div> </div> ";
if (I % 2 == 0)
CatalogProducts.InnerHtml += " <div class=\"row\"> <div style=\"position: relative\" class=\"col-lg-3 col-md-4 col-sm-6 col-xs-12 col-sm-push-1 animated bounceInLeft\"> <div class=\"hovereffect\"> <img class=\"img-responsive\" src= \".." + DSViewProducts.Tables[0].Rows[I][3].ToString() + "\"" + " alt=\"\"> <div class=\"overlay\"> <h2>Add to cart<span style=\"font-size: 0.65em\"></span> <asp:Button ID=\"Button1\" runat=\"server\" BackColor=\"Transparent\" BorderStyle=\"None\" ForeColor=\"Transparent\" Height=\"43px\" Style=Height=\"z-index: 99; left: 0px; position: absolute; top: 0px\" Text=\"a\" Width=\"87px\" /></h2> <p class=\"icon-links\">" + DSViewProducts.Tables[0].Rows[I][0].ToString() + "<br /> " + DSViewProducts.Tables[0].Rows[I][4].ToString() + " </p> </div> </div> </div> </div> <br /> <br /> <br /> <br />";
else CatalogProducts.InnerHtml += " <div style=\"position: relative\" class=\"col-lg-3 col-md-4 col-sm-6 col-xs-12 col-sm-push-1 animated bounceInLeft\"> <div class=\"hovereffect\"> <img class=\"img-responsive\" src= \".." + DSViewProducts.Tables[0].Rows[I][3].ToString() + "\"" + " alt=\"\"> <div class=\"overlay\"> <h2>Add to cart<span style=\"font-size: 0.65em\"></span> <asp:Button ID=\"Button1\" runat=\"server\" BackColor=\"Transparent\" BorderStyle=\"None\" ForeColor=\"Transparent\" Height=\"43px\" Style=Height=\"z-index: 99; left: 0px; position: absolute; top: 0px\" Text=\"a\" Width=\"87px\" /></h2> <p class=\"icon-links\">" + DSViewProducts.Tables[0].Rows[I][0].ToString() + "<br /> " + DSViewProducts.Tables[0].Rows[I][4].ToString() + " </p> </div> </div> </div> </div> <br /> <br />";
}
}
protected void Allbuttons_Click(object sender, EventArgs e)
{
string BTNID = ((Button)sender).ID.ToString();
Session["ItemName"] = BTNID;
Response.Redirect("ViewItem.aspx");
}
<div class="row">
<div style="position: relative" class="col-lg-3 col-md-4 col-sm-6 col-xs-12 col-sm-push-1 animated bounceInLeft">
<div class="hovereffect">
<img class="img-responsive" src="../User/Pictures/ShirtCheck.png" alt="">
<div class="overlay">
<h2>Add to cart<span style="font-size: 0.65em"></span>
<asp:Button ID="Button1" runat="server" BackColor="Transparent" BorderStyle="None"
ForeColor="Transparent" Height="43px" Style="z-index: 99; left: 0px; position: absolute;
top: 0px" Text="a" Width="87px" />
<p class="icon-links"></p>
</div>
</div>
</div>
protected List<string> ListOfStrings { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (ListOfStrings == null)
ListOfStrings = new List<string>();
ListOfStrings.Insert(0, "First item");
ListOfStrings.Insert(1, "Second item");
ListOfStrings.Insert(2, "Third item");
ListOfStrings.Insert(3, "Fourth item");
}
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<% for (int i = 0; i < ListOfStrings.Count(); i++)
{
%>
<p><%=ListOfStrings[i] %></p>
<% } %>
</asp:Content>