ASP.NET Podcast

ASP.NET Podcast is geared towards the Microsoft .NET Framework and ASP.NET.
The podcast is run by Wally and Paul.
Welcome to ASP.NET Podcast Sign in | Join | Help
in Search

ASP.NET Podcast

The ASP.NET Podcast features, technical talks, interviews, news, reviews, and Wallyisms. Wallace B. (Wally) McClure and Paul Glavich are your hosts.

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

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();
}
 

Published Wednesday, May 23, 2007 10:00 AM by admin
Anonymous comments are disabled
Powered by Community Server, by Telligent Systems