A
Alex. O. Koranteng
I am using LINQTOSQL as my dataaccess technique. I have a button on a page
for which will load a page using the postbackurl property. I have defined the
namespace for my dbml file as NwindLinqSProcs. The stored procedures for this
application in the methods pane of the layout file for the dbml file. I am
getting error below for the click event of the button. Please see below for
the code and will appreciate any suggestions
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="LinqCustomersSP.aspx.cs" Inherits="NwindWebSite.LinqCustomersSP"
%>
<!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>LinqDataSource Binding with LINQ to SQL Data Access Layer (DAL)
with Stored Procedures (C#)</title>
</head>
<body>
<form id="frmMain" runat="server">
<div style="text-align:center">
<asp:Label ID="lblHeader" runat="server" Font-Bold="True"
Font-Names="Calibri"
Font-Size="14pt" Text="LinqDataSource Binding with LINQ to SQL
Data Access Layer (DAL) with Stored Procedures (C#)"
Width="100%" Height="24px" ForeColor="#507CD1"></asp:Label>
</div>
<div>
<asp:GridView ID="gvCustomers" runat="server" CellPadding="4"
Font-Names="Calibri" Font-Size="11pt" ForeColor="#333333"
GridLines="None"
Width="100%" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="CustomerID"
DataSourceID="ldsCustomers">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<columns>
<asp:commandfield ShowEditButton="True" ShowSelectButton="True">
</asp:commandfield>
<asp:boundfield DataField="CustomerID" HeaderText="CustomerID"
ReadOnly="True"
SortExpression="CustomerID"></asp:boundfield>
<asp:boundfield DataField="CompanyName" HeaderText="CompanyName"
SortExpression="CompanyName"></asp:boundfield>
<asp:boundfield DataField="ContactName" HeaderText="ContactName"
SortExpression="ContactName"></asp:boundfield>
<asp:boundfield DataField="ContactTitle"
HeaderText="ContactTitle"
SortExpression="ContactTitle"></asp:boundfield>
<asp:boundfield DataField="Address" HeaderText="Address"
SortExpression="Address"></asp:boundfield>
<asp:boundfield DataField="City" HeaderText="City"
SortExpression="City">
</asp:boundfield>
<asp:boundfield DataField="Region" HeaderText="Region"
SortExpression="Region">
</asp:boundfield>
<asp:boundfield DataField="PostalCode" HeaderText="PostalCode"
SortExpression="PostalCode"></asp:boundfield>
<asp:boundfield DataField="Country" HeaderText="Country"
SortExpression="Country"></asp:boundfield>
<asp:boundfield DataField="Phone" HeaderText="Phone"
SortExpression="Phone">
</asp:boundfield>
<asp:boundfield DataField="Fax" HeaderText="Fax"
SortExpression="Fax">
</asp:boundfield>
</columns>
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
<div style="text-align:center;vertical-align: middle;">
<asp:LinkButton ID="lbOrdersSP" runat="server" BorderColor="White"
BorderWidth="7px" Font-Names="Calibri" Font-Size="11pt"
PostBackUrl="~/LinqOrdersSP.aspx" Width="223px"
style="margin-left: 0px">Orders
(Stored Procedures)</asp:LinkButton>
<asp:Button ID="btnAddBogus" runat="server" Font-Names="Calibri"
Font-Size="11pt" onclick="btnAddBogus_Click" Text="Add BOGUS
Customer"
Width="155px" />
<asp:Button ID="btnDeleteBogus" runat="server" Font-Names="Calibri"
Font-Size="11pt" onclick="btnDeleteBogus_Click" Text="Drop BOGUS
Customer"
Width="160px" />
<asp:LinkButton ID="lbObjectDS" runat="server" BorderColor="White"
BorderWidth="7px" Font-Names="Calibri" Font-Size="11pt"
PostBackUrl="~/ObjectDataSource.aspx"
Width="150px">ObjectDataSource</asp:LinkButton>
</div>
<asp:LinqDataSource ID="ldsCustomers" runat="server"
ContextTypeName="NwindLinqSProcsCS.NorthwindDataContext"
EnableDelete="True"
EnableInsert="True" EnableUpdate="True" TableName="Customers">
</asp:LinqDataSource>
</form>
</body>
</html>
Could not load type 'NwindLinqSProcsCS.NorthwindDataContext'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Web.HttpException: Could not load type
'NwindLinqSProcsCS.NorthwindDataContext'.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Could not load type
'NwindLinqSProcsCS.NorthwindDataContext'.]
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean
throwOnError, Boolean ignoreCase) +8819397
System.Web.UI.WebControls.LinqDataSourceView.get_ContextType() +93
for which will load a page using the postbackurl property. I have defined the
namespace for my dbml file as NwindLinqSProcs. The stored procedures for this
application in the methods pane of the layout file for the dbml file. I am
getting error below for the click event of the button. Please see below for
the code and will appreciate any suggestions
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="LinqCustomersSP.aspx.cs" Inherits="NwindWebSite.LinqCustomersSP"
%>
<!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>LinqDataSource Binding with LINQ to SQL Data Access Layer (DAL)
with Stored Procedures (C#)</title>
</head>
<body>
<form id="frmMain" runat="server">
<div style="text-align:center">
<asp:Label ID="lblHeader" runat="server" Font-Bold="True"
Font-Names="Calibri"
Font-Size="14pt" Text="LinqDataSource Binding with LINQ to SQL
Data Access Layer (DAL) with Stored Procedures (C#)"
Width="100%" Height="24px" ForeColor="#507CD1"></asp:Label>
</div>
<div>
<asp:GridView ID="gvCustomers" runat="server" CellPadding="4"
Font-Names="Calibri" Font-Size="11pt" ForeColor="#333333"
GridLines="None"
Width="100%" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="CustomerID"
DataSourceID="ldsCustomers">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<columns>
<asp:commandfield ShowEditButton="True" ShowSelectButton="True">
</asp:commandfield>
<asp:boundfield DataField="CustomerID" HeaderText="CustomerID"
ReadOnly="True"
SortExpression="CustomerID"></asp:boundfield>
<asp:boundfield DataField="CompanyName" HeaderText="CompanyName"
SortExpression="CompanyName"></asp:boundfield>
<asp:boundfield DataField="ContactName" HeaderText="ContactName"
SortExpression="ContactName"></asp:boundfield>
<asp:boundfield DataField="ContactTitle"
HeaderText="ContactTitle"
SortExpression="ContactTitle"></asp:boundfield>
<asp:boundfield DataField="Address" HeaderText="Address"
SortExpression="Address"></asp:boundfield>
<asp:boundfield DataField="City" HeaderText="City"
SortExpression="City">
</asp:boundfield>
<asp:boundfield DataField="Region" HeaderText="Region"
SortExpression="Region">
</asp:boundfield>
<asp:boundfield DataField="PostalCode" HeaderText="PostalCode"
SortExpression="PostalCode"></asp:boundfield>
<asp:boundfield DataField="Country" HeaderText="Country"
SortExpression="Country"></asp:boundfield>
<asp:boundfield DataField="Phone" HeaderText="Phone"
SortExpression="Phone">
</asp:boundfield>
<asp:boundfield DataField="Fax" HeaderText="Fax"
SortExpression="Fax">
</asp:boundfield>
</columns>
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"
ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</div>
<div style="text-align:center;vertical-align: middle;">
<asp:LinkButton ID="lbOrdersSP" runat="server" BorderColor="White"
BorderWidth="7px" Font-Names="Calibri" Font-Size="11pt"
PostBackUrl="~/LinqOrdersSP.aspx" Width="223px"
style="margin-left: 0px">Orders
(Stored Procedures)</asp:LinkButton>
<asp:Button ID="btnAddBogus" runat="server" Font-Names="Calibri"
Font-Size="11pt" onclick="btnAddBogus_Click" Text="Add BOGUS
Customer"
Width="155px" />
<asp:Button ID="btnDeleteBogus" runat="server" Font-Names="Calibri"
Font-Size="11pt" onclick="btnDeleteBogus_Click" Text="Drop BOGUS
Customer"
Width="160px" />
<asp:LinkButton ID="lbObjectDS" runat="server" BorderColor="White"
BorderWidth="7px" Font-Names="Calibri" Font-Size="11pt"
PostBackUrl="~/ObjectDataSource.aspx"
Width="150px">ObjectDataSource</asp:LinkButton>
</div>
<asp:LinqDataSource ID="ldsCustomers" runat="server"
ContextTypeName="NwindLinqSProcsCS.NorthwindDataContext"
EnableDelete="True"
EnableInsert="True" EnableUpdate="True" TableName="Customers">
</asp:LinqDataSource>
</form>
</body>
</html>
Could not load type 'NwindLinqSProcsCS.NorthwindDataContext'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Web.HttpException: Could not load type
'NwindLinqSProcsCS.NorthwindDataContext'.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Could not load type
'NwindLinqSProcsCS.NorthwindDataContext'.]
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean
throwOnError, Boolean ignoreCase) +8819397
System.Web.UI.WebControls.LinqDataSourceView.get_ContextType() +93