G
gh
I am using VS 2008. There datalist hase a filed, STATUS, that is 0, 1,
or 2. Depending on the value I want to set the Image source. I also
have a field with a description that I would like to concantenate to the
image, as the hyperlink or use a hyperlink filed for everything Below
is what I have for a function in the code behind:
protected string SetStatus(string aStatus)
{
if (aStatus == "0")
{
return "<img src = \"../images/image1.gif\" />";
}
else
if (aStatus == "0")
{
return "<img src = \"../images/image2.gif\" />";
}
}
In the aspx file below is the template markup.
<aspataList ID="DataList1" runat="server" RepeatColumns="3"
RepeatDirection="Horizontal" DataSourceID="SqlDataSource1"
onitemdatabound="DataList1_ItemDataBound">
<ItemTemplate>
<br />
STATUS:
<asp:Label ID="STATUSLabel" runat="server" Text='
<%# SetStstus(Convert.ToString(DataBinder.Eval(Container.DataItem,
"STATUS")))%>' />
<br />
<br />
</ItemTemplate>
</aspataList>
1. Can I add the markup to use an image and hyperlink for the cell?
2. When I try to view the page now I get the following error:
Compiler Error Message: CS0161: '_Default.SetStatus(string)': not
all code paths return a value
Line 98: }
Line 99:
Line 100: protected string SetStatus(string aStatus)
Line 101: {
Line 102: /* if (aStatus == "0")
The Status is stored as and integer but I am using a Convert.ToString in
the SetStatus call.
Waht would be the cause of the error?
TIA
or 2. Depending on the value I want to set the Image source. I also
have a field with a description that I would like to concantenate to the
image, as the hyperlink or use a hyperlink filed for everything Below
is what I have for a function in the code behind:
protected string SetStatus(string aStatus)
{
if (aStatus == "0")
{
return "<img src = \"../images/image1.gif\" />";
}
else
if (aStatus == "0")
{
return "<img src = \"../images/image2.gif\" />";
}
}
In the aspx file below is the template markup.
<aspataList ID="DataList1" runat="server" RepeatColumns="3"
RepeatDirection="Horizontal" DataSourceID="SqlDataSource1"
onitemdatabound="DataList1_ItemDataBound">
<ItemTemplate>
<br />
STATUS:
<asp:Label ID="STATUSLabel" runat="server" Text='
<%# SetStstus(Convert.ToString(DataBinder.Eval(Container.DataItem,
"STATUS")))%>' />
<br />
<br />
</ItemTemplate>
</aspataList>
1. Can I add the markup to use an image and hyperlink for the cell?
2. When I try to view the page now I get the following error:
Compiler Error Message: CS0161: '_Default.SetStatus(string)': not
all code paths return a value
Line 98: }
Line 99:
Line 100: protected string SetStatus(string aStatus)
Line 101: {
Line 102: /* if (aStatus == "0")
The Status is stored as and integer but I am using a Convert.ToString in
the SetStatus call.
Waht would be the cause of the error?
TIA