Hi Imar,
Apparently, something is wrong with my Default.aspx, from the PhotoAlbums folder. Checking it against your source code, I could not find a discrepancy.
Would u pls suggest a way to debug this problem or where it might be?
Thanks for your help. mk
Here is the exception from the browser:
Code:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Operator '==' incompatible with operand types 'Int32' and 'Object'
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.Query.Dynamic.ParseException: Operator '==' incompatible with operand types 'Int32' and 'Object'
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:
[ParseException: Operator '==' incompatible with operand types 'Int32' and 'Object']
System.Web.Query.Dynamic.ExpressionParser.CheckAndPromoteOperands(Type signatures, String opName, Expression& left, Expression& right, Int32 errorPos) +487761
System.Web.Query.Dynamic.ExpressionParser.ParseComparison() +577
System.Web.Query.Dynamic.ExpressionParser.ParseLogicalAnd() +25
System.Web.Query.Dynamic.ExpressionParser.ParseLogicalOr() +25
System.Web.Query.Dynamic.ExpressionParser.ParseExpression() +22
System.Web.Query.Dynamic.ExpressionParser.Parse(Type resultType) +25
System.Web.Query.Dynamic.DynamicExpression.ParseLambda(ParameterExpression[] parameters, Type resultType, String expression, Object[] values) +45
System.Web.Query.Dynamic.DynamicExpression.ParseLambda(Type itType, Type resultType, String expression, Object[] values) +67
System.Web.Query.Dynamic.DynamicQueryable.Where(IQueryable source, String predicate, Object[] values) +62
System.Web.UI.WebControls.DynamicQueryableWrapper.Where(IQueryable source, String predicate, Object[] values) +14
System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelectExpressions(IQueryable source, IDictionary`2 whereValues, IOrderedDictionary orderByOrderedValues, IDictionary`2 groupByValues, IDictionary`2 orderGroupsByValues, IDictionary`2 selectNewValues) +288
System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelectQuery(LinqDataSourceSelectEventArgs selectEventArgs, Object selectResult, Object table, Boolean storeOriginalValues) +327
System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +457
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +19
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
System.Web.UI.WebControls.ListView.PerformSelect() +57
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.ListView.CreateChildControls() +55
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +44
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
The Default.aspx page from the PhotoAlbums:
Code:
<%@ Page Title="All Photo Albums" Language="C#" MasterPageFile="~/MasterPages/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<%-- (R)DBying Technologies
--%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphMainContent" Runat="Server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="LinqDataSource1" DataTextField="Name" DataValueField="Id">
</asp:DropDownList>
<br />
<asp:ListView ID="ListView1" runat="server" DataKeyNames="Id"
DataSourceID="LinqDataSource2" onitemcreated="ListView1_ItemCreated">
<ItemTemplate>
<li style="">
<%-- an image control to display the picure --%>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# Eval("ImageUrl") %>'
ToolTip='<%# Eval("Tooltip") %>' />
<%-- a text to provide a description below the picure --%>
<asp:Label ID="DescriptionLabel" runat="server"
Text='<%# Eval("Description") %>' /><br />
<asp:Button ID="DeleteButton" CommandName="Delete" runat="server" Text="Delete" />
</li>
</ItemTemplate>
<EmptyDataTemplate>
No data was returned.
</EmptyDataTemplate>
<LayoutTemplate>
<ul class="itemContainer">
<li ID="itemPlaceholder" runat="server" />
</ul>
<div style="">
<asp:DataPager ID="DataPager1" runat="server" PageSize="3">
<Fields>
<%-- NextPreviousPager --%>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowLastPageButton="True" />
<%-- For Numeric Pager, uncomment the following --%>
<%--<asp:NumericPagerField NextPageText="..." PreviousPageText="..." />--%>
</Fields>
</asp:DataPager>
</div>
</LayoutTemplate>
</asp:ListView>
<%-- comment --%>
<asp:LinqDataSource ID="LinqDataSource2" runat="server"
ContextTypeName="LanicalDataContext"
TableName="Pictures"
Where="PhotoAlbumId == @PhotoAlbumId" EnableDelete="True">
<%-- WHERE parameter(s):
- ControlID -- the control from which the parameter is taken for the WHERE clause
- Name -- the name of the PK column in the table of interest
- PropertyName -- the corresponding value/parameter associated w/ the selected item in the drop down list,
to replace @PhotoAlbumId, in the WHERE stmt above --%>
<WhereParameters>
<asp:ControlParameter
ControlID="DropDownList1"
Name="PhotoAlbumId"
PropertyName="SelectedValue" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
<%-- comment --%>
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="LanicalDataContext"
Select="new (Id, Name)"
TableName="PhotoAlbums">
</asp:LinqDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
and the .cs file is
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ListView1_ItemCreated(object sender, ListViewItemEventArgs e)
{
switch (e.Item.ItemType)
{
case ListViewItemType.DataItem:
Button deleteButton = (Button)e.Item.FindControl("DeleteButton");
deleteButton.Visible=Roles.IsUserInRole("Managers");
break;
default:
break;
}
}
}