Scalable Development

Our professional opinions... because not everybody's got one.

This site maintained by Scalable Development, Inc. www.scalabledevelopment.com.

Welcome to Scalable Development Sign in | Join | Help
in Search

wallym

ASP.NET Podcast Show #93 - ASP.NET ListView in Orcas Beta 1 - Video

Original URL: http://aspnetpodcast.com/CS11/blogs/asp.net_podcast/archive/2007/05/23/asp-net-podcast-show-93-asp-net-listview-in-orcas-beta-1-video.aspx

Subscribe

Download WMV

Download MP4

Show Notes:

  • ASP.NET ListView.
  • ListView as a Grid.
  • ListView as a Container of data.

Source Code:

ASPX Page:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ListView.aspx.cs" Inherits="ListView" %>
<!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>ListView Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ListView ID="ListView1" runat="server" ItemContainerID="tblData">
    <layouttemplate>
        <table border="1">
            <tr>
                <th>Name</th>
            </tr>
            <tbody runat="server" id="tblData"></tbody>
        </table>
    </layouttemplate>
    <itemtemplate>
    <tr>
        <td><%# Eval("Name") %></td>
    </tr>
    </itemtemplate>
    </asp:ListView>
    <asp:ListView ID="ListView2" runat="server" ItemContainerID="ddlSelect">
    <LayoutTemplate>
        <select ID="ddlS" name="ddlS">
            <asp:PlaceHolder ID="ddlSelect" runat="server"></asp:PlaceHolder>
        </select>
    </LayoutTemplate>
    <ItemTemplate>
        <option><%# Eval("Name") %></option>
    </ItemTemplate>
    </asp:ListView>
    </div>
    </form>
</body>
</html>

Code Behind .cs file:

protected void Page_Load(object sender, EventArgs e)
{
    DataTable dtData = new DataTable();
    DataRow drData;
    dtData.Columns.Add( "Name", System.Type.GetType("System.String"));
    drData = dtData.NewRow();
    drData["Name"] = "Wally McClure";
    dtData.Rows.Add(drData);
    drData = dtData.NewRow();
    drData["Name"] = "Paul Glavich - my trusty sidekick";
    dtData.Rows.Add(drData);
    ListView1.DataSource = dtData;
    ListView1.DataBind();
    ListView2.DataSource = dtData;
    ListView2.DataBind();
}

PS.  Due to a snafu with my DNS Server, the site was inaccessible for a while today.  As a result, I took this post offline and put it back on once the server was back up and going.
Published Wednesday, May 23, 2007 10:00 AM by wallym Edit

Comments

No Comments
Anonymous comments are disabled

This Blog

Post Calendar

<May 2007>
SuMoTuWeThFrSa
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Syndication

Powered by Community Server, by Telligent Systems