Hi guys!
I have a question about ASP.NET data binding. I'm creating a site that
displays news for some artist...the main page
News.aspx contains the whole list of news ordered by date descending....
and each news item has a
Read More html link that points to a
ViewNews.aspx?id={id} page than a news id is passed through a query string..
The
ViewNews.aspx page displays
EXTENDED info about artist....
some news items have photos some don't....
I have an SQL Server table
CREATE TABLE News(
[News ID] uniqueidentifier PRIMARY KEY NOT NULL DEFAULT NEWID(),
[Title] nvarchar(500) NOT NULL,
[Digest] nvarchar(3000) NOT NULL,
[Content] ntext NOT NULL,
[PhotoLink] varchar(100) NULL
);
The point is that ...I want to fully show my news item correctly...
if a news item doesn't have an associated image than I don't need to insert image into HTML, if there is an associated image with that news item then
it must be floatted left and text must be floated right
I do this:
<asp:SqlDataSource ID = "srcNewsSolo" runat = "server"
ConnectionString="<%$ ConnectionStrings:MusicDBConnString %>"
SelectCommand="SELECT [Title], [Content], [PhotoLink] FROM [News] WHERE ([News ID] = @News_ID)">
<SelectParameters>
<asp:QueryStringParameter Name="News_ID" QueryStringField="id" />
</SelectParameters>
<asp:DataList id = "soloNewsItem" DataSourceID = "srcNewsSolo" runat = "server>
<itemtemplate>
<span style="color: Orange;"><%# Eval("Title") %> </span>
<% if ( Eval("PhotoLink") != null) { %>
<img src = "<%# Eval("PhotoLink") %>" style = "float: left; " />
<% } %>
<span style="color: White"> <%# Eval("Content") %> </span>
</itemtemplate>
I have some errors here ...how to fix them??? how to use Container.DataItem???
I don't have in Intellisense!!!!!!! How to dynamically decide whether to render photo or not .... Please help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!