LinqDatasource SessionParameter Operator '==' incompatible with operand types 'Int32' and 'Object'

Posted by Ouou under ASP.NET on 3/14/2011 | Points: 10 | Views : 3453 | Status : [Member] | Replies : 0
I set <sessionState mode="InProc" timeout="1800"> </sessionState> in web.config
On Login.aspx
protected void Button1_Click(object sender, EventArgs e)
{
Session["UserID"] = TextBox1.Text;
Response.Redirect("EditJob.aspx");
}

On my Error EditJob.aspx

<asp:LinqDataSource ID="LinqDataSourceMaster" runat="server"
ContextTypeName="JobPostDataContext" EntityTypeName="" Select="new (JobID, JobTitle, UserID)"
TableName="JobLists" Where="UserID == @UserID">
<WhereParameters>
<asp:SessionParameter DefaultValue="0" Name="UserID" SessionField="UserID"
Type="Int32" />
</WhereParameters>

</asp:LinqDataSource>

I also tried on EditJob.aspx

<asp:LinqDataSource ID="LinqDataSourceMaster" runat="server"
ContextTypeName="JobPostDataContext" EntityTypeName="" Select="new (JobID, JobTitle, UserID)"
TableName="JobLists" Where="UserID == @UserID"
onselecting="LinqDataSourceMaster_Selecting">
<WhereParameters>
<asp:SessionParameter DefaultValue="0" Name="UserID" SessionField="UserID"
Type="Int32" />
</WhereParameters>

</asp:LinqDataSource>
public partial class EditJob : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void LinqDataSourceMaster_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
foreach (KeyValuePair<string, object> kvp
in e.WhereParameters)
{
if (kvp.Value == null)
{
e.Cancel = true; return;
}
}
}


But it still shows

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'


How to solve this problem?




Responses

(No response found.)

Login to post response