Skip to content
March 19, 2008 / kiranpatils

CS1502+Eval+GridView+invalid arguments

Yesterday was binding my grid with function.. But it is showing me some errors which is as under

Server Error in ‘/DevelopmentWebsite’ Application.

Compilation Error
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: CS1502: The best overloaded method match for ‘SellBooking_EventSearch.GetEntityPriceText(double?, int?)’ has some invalid arguments

Source Error:

Line 133:
Line 134:
Line 135:                                       <asp:Label ID=”entityPrice” Text='<%# GetEntityPriceText(Eval(“entityPriceField”),Eval(“entityPriceCountField”))%>’ CssClass=”SearchBookingsLabelStyle” runat=”Server” />          


protected string GetEntityPriceText(Nullable<double> entityprice,Nullable<int> entityPriceCount)
//If count>1 then show text in HyperLink
string labelText = string.Empty;
if (entityPriceCount > 1)
//To-DO Change it to appropriate ASP Page
labelText = “<a href=’Booker.aspx’>” + entityprice.ToString() + “</a>”;
labelText = entityprice.ToString();
return labelText;

Solution and Cause of Error:

Cause of Error: Eval function returns object and my function expects double/int so it throws invalid arguments.

So just need to cast my Evals to appropriate type for my example double/ now it looks like this:

<asp:Label ID=”entityPrice” Text='<%# GetEntityPriceText((double)Eval(“entityPriceField”),(int)Eval(“entityPriceCountField”))%>’ CssClass=”SearchBookingsLabelStyle” runat=”Server” />      

It ran like a charm.

Hope it will help…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: