Click here to Skip to main content
15,896,606 members

ASP net help 2 questions

Nick Reshetinsky asked:

Open original thread
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???
Tags: C# (C# 2.0, C# 3.0), .NET (.NET 3.0, .NET 3.5), ASP, ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900