can you helped me in this code...i am only a beginner of asp.net but seems it always like this.i buy two books of wrox but the sample is always not compiling..
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'CAM' is not declared.
Source Error:
Line 92: <asp:TemplateColumn SortExpression="Author" HeaderText="Author">
Line 93: <ItemTemplate>
Line 94: <asp:Label id="Label1" runat="server"> <%# CAM.Formatting.MyCstr(Container.DataItem("Author") , True, False) %> </asp:Label>
Line 95: </ItemTemplate>
Line 96: </asp:TemplateColumn>
Source File: C:\Inetpub\wwwroot\GuestbookKO\NewFile.aspx Line: 94
this is the main code:
<%@ Page Language="
VB" Debug="true" %>
<%@ Register TagPrefix="CAM" TagName="Menu" Src="header.ascx" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Not Page.IsPostBack Then
' Databind the data grid on the first request only
' (on postback, rebind only in paging and sorting commands)
BindGrid()
End If
End Sub
Property SortField() As String
Get
Dim o As Object = ViewState("SortField")
If o Is Nothing Then
Return String.Empty
End If
Return CStr(o)
End Get
Set(ByVal Value As String)
ViewState("SortField") = Value
End Set
End Property
Sub DataGrid_Page(Sender As Object, e As DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
Sub DataGrid_Sort(Sender As Object, e As DataGridSortCommandEventArgs)
DataGrid1.CurrentPageIndex = 0
SortField = e.SortExpression
BindGrid()
End Sub
Sub BindGrid()
Dim CommandText As String
' TODO: update the CommandText value for your application
If SortField = String.Empty Then
CommandText = "select Author, Subject, Message, PostedDate from GuestBookEntries order by PostedDate desc"
Else
CommandText = "select Author, Subject, Message, PostedDate from GuestBookEntries order by " & SortField
End If
Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("C AM"))
Dim myCommand As New SqlDataAdapter(CommandText, myConnection)
Dim ds As New DataSet()
myCommand.Fill(ds)
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End Sub
</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<h2>
<CAM:Menu id="Menu" title="Guest Book" runat="server"></CAM:Menu>
</h2>
<form runat="server">
<asp:datagrid id="DataGrid1" runat="server" OnSortCommand="DataGrid_Sort" OnPageIndexChanged="DataGrid_Page" width="80%" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" PageSize="6" ForeColor="Black" BackColor="White" CellPadding="3" GridLines="None" CellSpacing="1">
<HeaderStyle font-bold="True" forecolor="White" backcolor="#4A3C8C"></HeaderStyle>
<PagerStyle horizontalalign="Right" backcolor="#C6C3C6" mode="NumericPages"></PagerStyle>
<ItemStyle backcolor="#DEDFDE"></ItemStyle>
<Columns>
<asp:TemplateColumn SortExpression="Author" HeaderText="Author">
<ItemTemplate>
<asp:Label id="Label1" runat="server"> <%# CAM.Formatting.MyCstr(Container.DataItem("Author") , True, False) %> </asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</form>
</body>
</html>
belmin