Repeater da Hashtable Kullanımı

 

Merhaba arkadaşlar bu makalemizde Repeater nesnesinde hashtable  kullanımına örnek vereceğiz.

 


 











Sekil 1

 

WebForm1.aspx.cs

 

using System;

using System.Collections;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

namespace aspnet_repeater_bind_the_hashtable

{

public partial class WebForm1 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

 

{

 

Hashtable name = new Hashtable();

 

name.Add("Bahadir Sahin",90);

name.Add("Melissa Parker", 80);

name.Add("Tommy Paton", 75);

name.Add("Alice May", 64);

name.Add("Michael Alon", 55);

name.Add("Mike Carson", 86);

name.Add("Tracy Abbot", 97);

name.Add("Nancy White", 88);

name.Add("Jack Fox", 69);

name.Add("Alina Benson", 91);

name.Add("Joe Eagle", 81);

name.Add("Johanna Manson", 82);

name.Add("Emilia Peterson", 73);

name.Add("Anna Rice", 84);

name.Add("Carla Thompson", 65);

name.Add("John Gray", 77);

name.Add("Richard Cunningham", 83);

name.Add("Camille Bernard", 67);

name.Add("Fynn Zimmermann", 59);

 

Repeater1.DataSource = name;

Repeater1.DataBind();

 

}

  }

}

 

WebForm1.aspx

     

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="aspnet_repeater_bind_the_hashtable.WebForm1" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

        <div>

            <asp:Repeater ID="Repeater1" runat="server">

                <HeaderTemplate>

    <ul>

  </HeaderTemplate>

  <ItemTemplate>

    <li><%# DataBinder.Eval(Container.DataItem, "Key") %> -

    <%# DataBinder.Eval(Container.DataItem, "Value") %></li>

  </ItemTemplate>

  <FooterTemplate>

    </ul>

  </FooterTemplate>

            </asp:Repeater>

        </div>

    </form>

</body>

</html>

 

 

Bir makalenin daha sonuna geldik. Bir sonraki makalede gorusmek uzere. Bahadir SAHIN

About Bahadır Şahin

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.

0 comments:

Öne Çıkan Yayın

GridView da Seçili Satırı DetailsView da Göstermek

Merhaba arkadaşlar bu makalemizde GridView nesnesi ile birlikte DetailsView nesanesini birlikte kullanacağız. GridView da seçili satırın de...