Hi guys!
I have two questions:
First: how to preserve all the line-breaks and whitespaces in SQL Server table.
I'm creating an
.aspx page to display the latest news in some area.
<asp:SqlDataSource ID = "srcNews" runat = "server"
ConnectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\TranceSiteDB.mdf;Integrated Security=True;User Instance=True"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT [NewsItemTitle], [NewsItemContent], [DT], [NewsItemLink] FROM [News] ORDER BY [DT] DESC">
<asp:DataList ID = "listNews" runat = "server" DataSourceID = "srcNews"
EnabViewState = "false">
<HeaderTemplate>
<span style="color: Orange; font-size: x-large; margin-removed 15px;">Latest news </span>
<br />
</HeaderTemplate>
<itemtemplate>
<div style="border: 1px solid white; removed: relative; padding: 5px 10px 0px 10px; margin-removed 15px; margin-removed 10px; margin-removed 10px;" önmouseover="this.className = 'hot_ITEM';" önmouseout="this.className = null;">
<span style="color: Orange; font-size: larger;"><%# this.Eval("NewsItemTitle") %></span>
<br />
<span style="color: White;"><%# this.Eval("NewsItemContent") %></span>
<br />
<span style="color: Lime; font-weight: bolder; removed: absolute; removed 5px; removed auto; margin-removed 0px; margin-removed auto; removed 0;"><%# this.Eval("DT", "{0:d}") %></span>
<a href="<%# Eval(" newsitemlink=") %>" style="margin-removed 5px;">Read More...</a>
</div>
</itemtemplate>
I use asp:DataList control to bind to my SQL source:
My SQL Server table structure:
NewsItemID uniqueidentifier PRIMARY KEY NOT NULL DEFAULT NEWID( ),
NewsItemTitle nvarchar(500) NOT NULL,
NewsItemContent ntext NOT NULL,
DT datetime NOT NULL,
NewsItemLink nvarchar(500) NOT NULL
When I bind to the
NewsItemContent
column through
"pre"
tag it shows me a LONG ---- VERY LONG!!! line of text...
How to save all the linebreaks when inserting data into SQL SERVER
(to insert data into SQL server I simply
COPY/PASTE text files
and insert data into SQL table cell as one line)
Second question:
<a href="<%# Eval(" newsitemlink=") %>" style="margin-removed 5px;">Read More...</a>
When I try to bind to the links column of a table I cannot bind to
anchor link.. It's because of symbol
" "
how to fix it???