Monday, January 26, 2009

ListView Sample - Asp.net 3.5 C# vb with datapager

When I first did program got following error:
An item placeholder must be specified on ListView 'ListView1'. Specify an item placeholder by setting a control's ID property to "itemPlaceholder". The item placeholder control must also specify runat="server".
after google many site got help and created first ListView program using sql-server.
 
 
 
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!

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>Untitled Page</title>

</

head>

<

body>

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

<div>

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" ItemPlaceholderID="LeadRep">

<LayoutTemplate>

<div id="LeadRep" runat="server"></div>

</LayoutTemplate>

<ItemTemplate>

<div><%# DataBinder.Eval(Container.DataItem,"LeadType") %></div>

<div><%# DataBinder.Eval(Container.DataItem,"HomePhone") %></div>

</ItemTemplate>

</asp:ListView>

<asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="5">

<

fields><asp:nextpreviouspagerfield ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" /><asp:numericpagerfield />

<

asp:nextpreviouspagerfield ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False"

ShowPreviousPageButton

="False" />

</

fields>

</

asp:DataPager>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ConnectionString="<%$ ConnectionStrings:SalesforceConnectionString %>"

SelectCommand="SELECT * FROM [SF_TranData]"></asp:SqlDataSource>

</div>

</form>

</

body>

</

html>

No comments: