Created
June 3, 2018 02:09
-
-
Save WildGenie/63ea481912b2ba2ba3f246d06b7444cd to your computer and use it in GitHub Desktop.
Asp.net İç İçe Repeater Örneği
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="altkategori.aspx.cs" Inherits="altkategori" %> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head runat="server"> | |
<title></title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<div> | |
<h1>Kategoriler | |
</h1> | |
</div> | |
<ul> | |
<asp:Repeater ID="rptKategori" runat="server" OnItemDataBound="rptKategori_ItemDataBound"> | |
<ItemTemplate> | |
<li><asp:HyperLink ID="HyperLink1" NavigateUrl='<%# String.Format("~/{0}/", DataBinder.Eval(Container.DataItem, "KategoriAdi")) %>' runat="server"><%#Eval("KategoriAdi") %></asp:HyperLink> | |
<ul> | |
<asp:Repeater runat="server" ID="altmenu"> | |
<ItemTemplate> | |
<li> | |
<asp:HyperLink ID="HyperLink1" NavigateUrl='<%# String.Format("~/{0}/{1}", DataBinder.Eval(Container.DataItem, "KategoriAdi"), DataBinder.Eval(Container.DataItem, "AltKategoriAdi")) %>' runat="server"><%#Eval("AltKategoriAdi") %></asp:HyperLink> | |
</li> | |
</ItemTemplate> | |
</asp:Repeater> | |
</ul> | |
</li> | |
</ItemTemplate> | |
</asp:Repeater> | |
</ul> | |
</form> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
public partial class altkategori : Page | |
{ | |
List<Kategori> kategoriler = null; | |
List<AnaKategori> anaKategoriler = null; | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
if (!IsPostBack) | |
{ | |
kategoriler = new List<Kategori> | |
{ | |
new Kategori { KategoriAdi = "Konut", AltKategoriAdi = "Bina"}, | |
new Kategori { KategoriAdi = "Konut", AltKategoriAdi = "Çiftlik"}, | |
new Kategori { KategoriAdi = "Konut", AltKategoriAdi = "Daire"}, | |
new Kategori { KategoriAdi = "Ticari", AltKategoriAdi = "İşyeri"}, | |
new Kategori { KategoriAdi = "Ticari", AltKategoriAdi = "Ofis"}, | |
new Kategori { KategoriAdi = "Ticari", AltKategoriAdi = "Dükkan"}, | |
}; | |
anaKategoriler = new List<AnaKategori> | |
{ | |
new AnaKategori { KategoriAdi = "Konut",}, | |
new AnaKategori { KategoriAdi = "Ticari"}, | |
}; | |
rptKategori.DataSource = anaKategoriler; | |
rptKategori.DataBind(); | |
} | |
} | |
protected void rptKategori_ItemDataBound(object sender, RepeaterItemEventArgs e) | |
{ | |
Repeater rp = (Repeater)e.Item.FindControl("altmenu"); | |
rp.DataSource = kategoriler.Where(k => k.KategoriAdi == DataBinder.Eval(e.Item.DataItem, "KategoriAdi").ToString()).ToList(); | |
rp.DataBind(); | |
} | |
class Kategori | |
{ | |
public string KategoriAdi { get; set; } | |
public string AltKategoriAdi { get; set; } | |
} | |
class AnaKategori | |
{ | |
public string KategoriAdi { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment