Repeater导航菜单DataList产品展示
Posted 哈喽!树先生
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Repeater导航菜单DataList产品展示相关的知识,希望对你有一定的参考价值。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JD.aspx.cs" Inherits="WebApplication3.JD" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style type="text/css"> .style1 { width: 100%; } .style2 { width: 237px; } </style> </head> <body> <form id="form1" runat="server"> <div> <table class="style1"> <tr> <td class="style2"> <ul> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <li> <%# Eval("name") %> <hr /> <asp:HiddenField ID="HiddenField1" Value=‘<%# Eval("id") %>‘ runat="server" /> <ul> <asp:Repeater ID="Repeater2" runat="server"> <ItemTemplate> <li> <asp:LinkButton ID="LinkButton1" CommandArgument=‘<%# Eval("id") %>‘ OnClick="ShowList" runat="server"><%# Eval("Name") %></asp:LinkButton> </li> </ItemTemplate> </asp:Repeater> </ul> </li> </ItemTemplate> </asp:Repeater> </ul> </td> <td> <asp:DataList ID="DataList1" runat="server" CellPadding="4" ForeColor="#333333" RepeatColumns="4"> <AlternatingItemStyle BackColor="White" /> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <ItemStyle BackColor="#E3EAEB" /> <ItemTemplate> <table class="style1"> <tr> <td> <asp:Image ID="Image1" runat="server" Height="100px" ImageUrl=‘<%# Eval("pic") %>‘ Width="100px" /> </td> </tr> <tr> <td> <asp:Label ID="Label1" runat="server" Text=‘<%# Eval("name") %>‘></asp:Label> </td> </tr> </table> </ItemTemplate> <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> </asp:DataList> </td> </tr> </table> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication3 { public partial class JD : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BinList(); } } public void ShowList(object sender, EventArgs e) { LinkButton lb= sender as LinkButton; string id = lb.CommandArgument; Response.Write("查询类别:" + id + "对应的商品"); string sql = "select * from goods where cid=" + id; DataList1.DataSource = SQLHelper.GetTable(sql); DataList1.DataBind(); } private void BinList() { string sql = "select * from goodsClass where pid=0"; Repeater1.DataSource = SQLHelper.GetTable(sql); Repeater1.DataBind(); foreach (RepeaterItem item in Repeater1.Items) { string id = (item.FindControl("HiddenField1") as HiddenField).Value; Repeater p2 = item.FindControl("Repeater2") as Repeater; string s2 = "select * from goodsClass where pid=" + id; p2.DataSource = SQLHelper.GetTable(s2); p2.DataBind(); } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication3 { public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (TextBox2.Text == "123") { System.Web.Security.FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false); } } } }
以上是关于Repeater导航菜单DataList产品展示的主要内容,如果未能解决你的问题,请参考以下文章
gridview ,repeater,datalist有啥区别
为 asp.net 的 DataList/Repeater 实现寻呼机
GridView,DataList,Repeater 分别指啥.各有啥特点?