M
mikepolitowski
Hi folks,
I am have been trying to solve this problem for quite some time now and
would appreciate any advice. I have been trying to call a code-behind
function that is defined in my aspx.cs from within a DataList
<ItemTemplate> block using the <%# %> syntax. I would not have written
here if I had not spent over 6 hours trying to find a solution to this
problem again any advice is greatly appreciated.
I have included a code snippet below of the HTML code inside my .aspx
page. This code is found between the <ItemTemplate></ItemTemplate>
tags. (I have excluded the rest of the code to reduce spam; if you
need more information please let me know).
<asp:HyperLink ID="imgCovertResult"
NavigateUrl="InterviewQuestions.aspx?catId=<%#
DataBinder.Eval(Container.DataItem, "cat_id") %>"
ImageUrl="<%# GetResultImage(DataBinder.Eval(Container.DataItem,
"cat_id"), DataBinder.Eval(Container.DataItem, "covert_cutpoint_min"))
%>">
</asp:HyperLink>
Here is a small snippet of the .aspx.cs file that is associated with
the page. I have included a header to show class creation and the
function definition that resides within.
namespace Company1.WebUI.Admin
{
/// <summary>
/// Display Report Summaries for general users and display an Invalid
Surveys grid for Admin users
/// </summary>
public class AtRiskCategories :
Company1.WebUI.Admin.UIComponents.PageBase
{
..... more code ....
public string GetResultImage( int cat_id, int covert_cutpoint )
{
string sql;
DataSet ds;
int score;
......more code...
}
When I compile everything I get no compiler erros but when I then go to
the page I get this error msg,
Compiler Error Message: CS0103: The name 'GetResultImage' does not
exist in the current context
If I remove the line <%#
GetResultImage(DataBinder.Eval(Container.DataItem, "cat_id"),
DataBinder.Eval(Container.DataItem, "covert_cutpoint_min")) %> it
works like a charm, but that was expected. (Note: I do properly
populate the DataList with a valid DataSet and the results are correct
when the line above is omitted).
I have tried so hard to figure this out I am just hitting my head
against the wall. I have tried everything I can think of. I have a
book that tells me that it is possible to call a code-behind function
like this within a DataList (and my syntax above is almost exact). Any
advice or suggestions are greatly appreciated. Thank you for reading
this!
Best Regards,
Mike P
I am have been trying to solve this problem for quite some time now and
would appreciate any advice. I have been trying to call a code-behind
function that is defined in my aspx.cs from within a DataList
<ItemTemplate> block using the <%# %> syntax. I would not have written
here if I had not spent over 6 hours trying to find a solution to this
problem again any advice is greatly appreciated.
I have included a code snippet below of the HTML code inside my .aspx
page. This code is found between the <ItemTemplate></ItemTemplate>
tags. (I have excluded the rest of the code to reduce spam; if you
need more information please let me know).
<asp:HyperLink ID="imgCovertResult"
NavigateUrl="InterviewQuestions.aspx?catId=<%#
DataBinder.Eval(Container.DataItem, "cat_id") %>"
ImageUrl="<%# GetResultImage(DataBinder.Eval(Container.DataItem,
"cat_id"), DataBinder.Eval(Container.DataItem, "covert_cutpoint_min"))
%>">
</asp:HyperLink>
Here is a small snippet of the .aspx.cs file that is associated with
the page. I have included a header to show class creation and the
function definition that resides within.
namespace Company1.WebUI.Admin
{
/// <summary>
/// Display Report Summaries for general users and display an Invalid
Surveys grid for Admin users
/// </summary>
public class AtRiskCategories :
Company1.WebUI.Admin.UIComponents.PageBase
{
..... more code ....
public string GetResultImage( int cat_id, int covert_cutpoint )
{
string sql;
DataSet ds;
int score;
......more code...
}
When I compile everything I get no compiler erros but when I then go to
the page I get this error msg,
Compiler Error Message: CS0103: The name 'GetResultImage' does not
exist in the current context
If I remove the line <%#
GetResultImage(DataBinder.Eval(Container.DataItem, "cat_id"),
DataBinder.Eval(Container.DataItem, "covert_cutpoint_min")) %> it
works like a charm, but that was expected. (Note: I do properly
populate the DataList with a valid DataSet and the results are correct
when the line above is omitted).
I have tried so hard to figure this out I am just hitting my head
against the wall. I have tried everything I can think of. I have a
book that tells me that it is possible to call a code-behind function
like this within a DataList (and my syntax above is almost exact). Any
advice or suggestions are greatly appreciated. Thank you for reading
this!
Best Regards,
Mike P