Question Locked

Problem in calling code behind method from aspx page

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am having problem calling a method defined in the code behind of a page.\n

The method as defined in the code behind (default.aspx.cs):-

public void ShowRating(object objRate,string strId)
{
int nRate = Convert.ToInt32(objRate);
for (int nLoop = 0; nLoop < nRate; nLoop++)
{
HtmlGenericControl objImg = new HtmlGenericControl("img");
objImg.Attributes.Add("src","images/rate.jpg");
this.ParseControl(strId).Controls.Add(objImg);
}
}

The same method is being caled in the corresponding aspx page(default.aspx) as shown :-

<%#DataBinder.Eval(Container.DataItem, "title1")%>

Duration :
<%#DataBinder.Eval(Container.DataItem, "duration1")%>
Rating :
<%#ShowRating(DataBinder.Eval(Container.DataItem, "rate1"), "rating1")%>

When I compile, it gives the following error.
1. error CS1502: The best overloaded method match for 'System.Convert.ToString(object, System.IFormatProvider)' has some invalid arguments.

2. error CS1503: Argument '1': cannot convert from 'void' to 'object'.

Thanks for the solution in advance.....

1 reply

This discussion is closed to new replies.