Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datalist control

Reply
Thread Tools

Datalist control

 
 
Yoshitha
Guest
Posts: n/a
 
      09-28-2005
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




 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      09-28-2005
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
"Yoshitha" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Entering DataList EditItemTemplate from Outside of the DataList Luis Esteban Valencia ASP .Net 1 01-06-2005 07:32 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Click event in a datalist to post back datalist properties Steve Lloyd ASP .Net 1 05-26-2004 04:07 AM
DataList in DataList acko bogicevic ASP .Net 2 11-11-2003 08:31 AM
Datalist in Datalist How? Gönen EREN ASP .Net 0 08-22-2003 02:41 PM



Advertisments