Datalist control

Y

Yoshitha

Hello,

I have a doubt...
I have a TextBox by name txtMessage.Text ,Button by name btnSend and
Datalist Control by name dltMessage i my aspx page.

when i enter the data in text box and click on the button it is storing
the data into the database.
The saved information has to displayed in the datalist....


Here the problem is for example when i enter data like this in the text box
" Hello Sir,
I have completed Msc Computer
Science from Gitam College..
and i am working as a SE at Nanna Computers Pvt Ltd.
and i am staying in Hyderabad."


I have entered like this data in the text box and pressed submit button.
the data stored in the database in which format i entered that manner only
it entered ...

code:

txtMessage.Text = txtMessage.Text.Replace(Environment.NewLine, "<br>")
txtMessage.Text = txtMessage.Text.Replace(" ", "&nbsp;")
msg.MessageText = txtMessage.Text.Replace("'", " ")
msg.SentOn = Now
msg.Send() this is to store the data into the database.

Now when i am retreving into the data list it is not properly displaying
in the data list.... The problem i identified the data list only accepts
HTML data
so what i did is when i press enter i am attaching <BR> tag in the data
where i press enter ..... but only with problem is space when give space i
have attach "&nbsp" when i encounter space but this is not the solution
since for one space i am storing 6 letters information in the data base

displaying in datagrid.


Dim Data As New DataTable
Dim DColumn As DataColumn
Dim DRow As DataRow
Dim s As System.Object

Dim startrec As Integer

If pageno = 1 Then
startrec = 0
Else
startrec = (pageno - 1) * PageSize
End If


Data = New DataTable("Files")

DColumn = New DataColumn("Message", GetType(String))
Data.Columns.Add(DColumn)
DColumn = New DataColumn("SentDate", GetType(String))
Data.Columns.Add(DColumn)
DColumn = New DataColumn("SenderID", GetType(String))
Data.Columns.Add(DColumn)

Dim i As Integer = 0

Dim DB As New Database
If DB.Run("Select SentDate, Message, SenderID from Messages where
ProjectID = '" & ProjID & "' order by SentDate Desc") Then
While DB.Result.Read
If i >= startrec And i <= (startrec + PageSize - 1) Then
DRow = Data.NewRow
DRow(0) = DB.Result("Message")
DRow(1) =
Convert.ToDateTime(DB.Result("SentDate")).ToString("d/M/yyyy")
DRow(2) =
UserFunctions.GetEmpFullName(DB.Result("SenderID"))
Data.Rows.Add(DRow)
End If
i = i + 1
End While
End If
dltMessages.DataSource = Data
dltMessages.DataBind()

If i > 12 Then
btnNext.Enabled = True
Else
btnNext.Enabled = False
End If

lblNoMsg.Visible = False
btnPrev.Visible = True
btnNext.Visible = True
lblMsgRange.Text = "(" & startrec + 1 & "-" & startrec +
dltMessages.Items.Count & ")" & " of " & New
Project(ProjID).MessageCount
If dltMessages.Items.Count = 0 Then
lblNoMsg.Visible = True
btnPrev.Visible = False
btnNext.Visible = False
lblMsgRange.Visible = False
Else
lblNoMsg.Visible = False
lblMsgRange.Visible = True
If pageno = 1 Then
btnPrev.Visible = False
End If

If pageno = PageCount Then
btnNext.Visible = False
End If

End If

End Sub

In this code i have some related to navigation ignore it ....

Please help me


Regards,
Krishna Murthy.K
 
S

S. Justin Gengo

Yoshita,

Try playing around with Server.HtmlEncode and Server.HtmlDecode.

I think these methods will help you out here.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top