Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DetailsView.aspx.cs" Inherits="DetailsViewPagerSettings" %>
<!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 id="Head1" runat="server">
<title>DetailsView Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorkConnectionString %>"
SelectCommand="SELECT * FROM [SalesLT].[Customer]" />
<asp:DetailsView ID="CustomerDetails" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true"
EmptyDataText="No data was found" DataKeyNames="CustomerID, RowGuid" EnablePagingCallbacks="True" PageIndex="5">
<PagerSettings Mode="NumericFirstLast"
PageButtonCount="20" Position="TopAndBottom" />
</asp:DetailsView>
<p>
<asp:Label runat="server" ID="lblInfo" />
</p>
</div>
</form>
</body>
</html>
Code Behind:
using System;
using System.Text;
using System.Web.UI;
public partial class DetailsViewPagerSettings : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
StringBuilder info = new StringBuilder();
info.AppendFormat("You are viewing record {0} of {1}<br />",CustomerDetails.DataItemIndex.ToString(),CustomerDetails.DataItemCount.ToString());
for (int i = 0; i < CustomerDetails.DataKeyNames.Length; i++)
{
info.AppendFormat("{0} : {1}<br />",CustomerDetails.DataKeyNames[i],CustomerDetails.DataKey.Values[i]);
}
info.AppendFormat("Selected Value : {0}",CustomerDetails.SelectedValue.ToString());
lblInfo.Text = info.ToString();
}
}
}
Not sure why the Label does not appear. I even added a Text in the label and that did not show up.
I'm very new to .Net, any help would be greatly appreciated.
Thanks,













