Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's wrong with this code?

Status
Not open for further replies.

asafblasberg

Programmer
Jun 22, 2004
21
US
Too many arguments to 'Private Function Highlight(spcShow As Object) As Object':

CODE

Private Function Highlight (spcShow As object)
If spcShow.Equals(DBNull.Value) Then
Return ""
End if
End Function

Goal: I have a datalist and I want to check for nulls, if it is null, do not display the data.

<asp:DataList id="displayproducts" HorizontalAlign="Center" cssclass = "gbhead" halign="center" ItemStyle-VerticalAlign="Top" itemstyle-horizontalalign= "Center" ItemStyle-Width = "300" width="100%" repeatlayout="table" runat="server">

<ItemStyle CssClass="dash"></ItemStyle>
<itemtemplate>
<p align="center">
<a href="viewproduct.aspx?pid=<%# DataBinder.Eval(Container.DataItem, ("idProduct"))%>&mcat=<%# DataBinder.Eval(Container.DataItem, ("mastercategory"))%>&id=<%# DataBinder.Eval(Container.DataItem, ("idcategory"))%>">
<asp:Image id="Image1" runat="server" src='<%# DataBinder.Eval(Container.DataItem, ("smallimageurl"))%>'>
</asp:Image></a><br>
<%# DataBinder.Eval(Container.DataItem, ("sku"))%><br>

<b><%# DataBinder.Eval(Container.DataItem, ("description"))%></b><br>

List Price: <%# DataBinder.Eval(Container.DataItem, ("listprice"), "{0:c}")%><br>
<b><font color="#CC0000">Sale Price: <%# DataBinder.Eval(Container.DataItem, ("price"), "{0:c}")%><br></font>
<b><font color="#CC0000">Special Price: <%# Highlight(DataBinder.Eval(Container.DataItem, "specialprice"), "{0:c}")%<br></font>

<span class="gbbig"><font color="#800000"><%# DataBinder.Eval(Container.DataItem, ("specialtext"))%></span>
</itemtemplate>

</asp:DataList>
 
Here's what you have:

Code:
Highlight( arg1, "{0:c}")

Where arg1 is:

Code:
DataBinder.Eval(Container.DataItem, "specialprice")

Naturally, your function only takes one argument, hence the error, but, then again, it doesn't appear to be set up to return anything (that is, unless it's a weird VB feature I'm not familiar with)...

Code:
Private Function Highlight (spcShow As object) [b]As Whatever[/b] 'As ... is missing

Additionally, the function should return the passed value in an else statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top