473,324 Members | 2,268 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Datalist control

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


Nov 19 '05 #1
1 1242
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" <gu**********@yahoo.co.in> wrote in message
news:uW*************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Malter | last post by:
I take it that the only way to add rows to a DataList control is through DataBind? If not, how do I manually add rows to a DataList control? I have searched everywhere and can't find an example...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
6
by: tshad | last post by:
I need to get to a status label I have on my footer section of my datalist. There is no event happening that would go to the footer. I am just doing some processing and want to update the label...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
1
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class...
1
by: Jim in Arizona | last post by:
I'm don't know how I would get around this. When working with a datalist control, there a specific built in commands (OnEditCommand, OnCancelCommand, etc). These commands, when the datalist...
6
by: Victor | last post by:
Hi. all I have a customize web control. I have three simple properties and customized render class. then I add this control into my datalist like <asp:DataList ID="datalist" runat="server"...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
4
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.