ASP website page error

Associate
Joined
17 Dec 2008
Posts
667
Hi, I'm using Microsoft Visual Studio. I keep getting this error when I try to view an ASP page in a web browser: 'Operator '==' incompatible with operand types 'Int32' and 'Object'.

I'm trying to configure the LinqDataSource Where Expression like this Column: restaurant, Operator: ==, Source: Control, Control ID: DropDownlist1.

What I'm trying to do is use a DropDownList and DetailsView. The DropDownList has list of restaurant names. When a name is selected it selects restaurantid. Then the restaurant details show in the DetailsView.

I read online that you have to put the default value as 0. When I do configure default value to 0, I get an empty Dropdownlist?

Configure data source LinqDataSource > Configure where expression > parameter properties > Default value.



Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" 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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <br />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>
                <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                    ContextTypeName="DataClassesDataContext" EntityTypeName="" OrderBy="restname" 
                    Select="new (restname, restaddress1, restaddress2, restaddress3, restpostcode, restupdatedate, restcomment, restimage, restemail, resttelno, restdescription, restaurantid, categoryid)" 
                    TableName="restaurants" Where="restaurantid == @restaurantid">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="DropDownList1" Name="restaurantid" 
                            PropertyName="SelectedValue" Type="Int32" />
                    </WhereParameters>
                </asp:LinqDataSource>
                <asp:DropDownList ID="DropDownList1" runat="server" 
                    DataSourceID="LinqDataSource1" DataTextField="restname" 
                    DataValueField="restaurantid">
                </asp:DropDownList>
                <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
                    DataSourceID="LinqDataSource1" Height="50px" Width="125px">
                    <Fields>
                        <asp:BoundField DataField="restname" HeaderText="restname" ReadOnly="True" 
                            SortExpression="restname" />
                        <asp:BoundField DataField="restaddress1" HeaderText="restaddress1" 
                            ReadOnly="True" SortExpression="restaddress1" />
                        <asp:BoundField DataField="restaddress2" HeaderText="restaddress2" 
                            ReadOnly="True" SortExpression="restaddress2" />
                        <asp:BoundField DataField="restaddress3" HeaderText="restaddress3" 
                            ReadOnly="True" SortExpression="restaddress3" />
                        <asp:BoundField DataField="restpostcode" HeaderText="restpostcode" 
                            ReadOnly="True" SortExpression="restpostcode" />
                        <asp:BoundField DataField="restupdatedate" HeaderText="restupdatedate" 
                            ReadOnly="True" SortExpression="restupdatedate" />
                        <asp:BoundField DataField="restcomment" HeaderText="restcomment" 
                            ReadOnly="True" SortExpression="restcomment" />
                        <asp:BoundField DataField="restemail" HeaderText="restemail" ReadOnly="True" 
                            SortExpression="restemail" />
                        <asp:BoundField DataField="resttelno" HeaderText="resttelno" ReadOnly="True" 
                            SortExpression="resttelno" />
                        <asp:BoundField DataField="restdescription" HeaderText="restdescription" 
                            ReadOnly="True" SortExpression="restdescription" />
                        <asp:BoundField DataField="restaurantid" HeaderText="restaurantid" 
                            ReadOnly="True" SortExpression="restaurantid" />
                        <asp:BoundField DataField="categoryid" HeaderText="categoryid" ReadOnly="True" 
                            SortExpression="categoryid" />
                    </Fields>
                </asp:DetailsView>
            </ContentTemplate>
        </asp:UpdatePanel>
        <br />
        <br />
        <br />
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        </asp:UpdatePanel>
        <br />
        <br />
        <br />
        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
        </asp:UpdatePanel>
        <br />
    
    </div>
    </form>
</body>
</html>
 
Back
Top Bottom