I’m getting an error when I try to do something like this below,
<% if (Eval("DescriptionShort") == "")
{ %>
There is no description for this winery
<%}
{ %>
<%# Eval("DescriptionShort") %>
<%}%>
The error I’m getting is,
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
Am I able to do something like this? If not can I do something in the code behind with this?
SqlDataAdapter adDetail = new SqlDataAdapter("SELECT * FROM TBLWineries WHERE WineryShow = 'True' AND WineryRegionFK =" + Request["WineryRegionID"], conn);
DataSet dsDetail = new DataSet();
adDetail.Fill(dsDetail);
Edit
It's a DataList with a table inside, I need that for the layout of the page. The next two lines of code show how I populate the DataList,
WineryListDL.DataSource = dsDetail;
WineryListDL.DataBind();
Someone elsewhere said I could use this, it doesn't give an error it doesn't display the else part! if "DescriptionShort" exists it works fine but if not I get no text.
<%# Eval("DescriptionShort") == "" ? "There is no description for this winery" : Eval("DescriptionShort") %>
Should that work, if so, it may be something to do with "DescriptionShort" not being null or ""???
Cheers,
Mike.