By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,305 Members | 1,901 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,305 IT Pros & Developers. It's quick & easy.

DataList Control

P: n/a

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 ...


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
startrec = (pageno - 1) * PageSize
End If
Data = New DataTable("Files")

DColumn = New DataColumn("Message", GetType(String))
DColumn = New DataColumn("SentDate", GetType(String))
DColumn = New DataColumn("SenderID", GetType(String))

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") )
End If
i = i + 1
End While
End If
dltMessages.DataSource = Data

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

lblNoMsg.Visible = False
btnPrev.Visible = True
btnNext.Visible = True
lblMsgRange.Text = "(" & startrec + 1 & "-" & startrec +
dltMessages.Items.Count & ")" & " of " & New
If dltMessages.Items.Count = 0 Then
lblNoMsg.Visible = True
btnPrev.Visible = False
btnNext.Visible = False
lblMsgRange.Visible = False
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
Krishna Murthy.K

Sep 28 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.