Datalist control

Discussion in 'ASP .Net' started by Yoshitha, Sep 28, 2005.

  1. Yoshitha

    Yoshitha Guest


    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) =
    DRow(2) =
    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
    Yoshitha, Sep 28, 2005
    1. Advertisements

  2. Yoshita,

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

    I think these methods will help you out here.


    S. Justin Gengo, MCP
    Web Developer / Programmer

    "Out of chaos comes order."
    S. Justin Gengo, Sep 28, 2005
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.