FeenyFan123
FeenyFan123

Reputation: 27

ASP VB Add to textbox

I have a asp vb page that holds store hours. I'm supposed to add a textbox that has a list of people's emails in it. The emails come from a database, someone else wrote the code for that. But I need to be able to fill a textbox with these emails and have the textbox editable so someone can change or add new emails. So how do you get it so the textbox automatically fills up with the emails? I have a textbox on the asp page. And I have some code on the vb page to try to fill it but nothing shows up in textbox. Please help, I'm very new at this!

Asp:

    <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Label ID="label1" Text="List Of Emails" runat="server" /> <br />
            <asp:TextBox ID="emailBox" TextMode="MultiLine" runat="server" />
            <br/><br/>
            <asp:Button Text="Save" runat="server" />
            <asp:Button Text="Cancel" runat="server" />
        </div>
    </form>
</body>
</html>

VB:

    Partial Class KioskEmailUpdate
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

        Try

            Dim tempstoreID As Integer = 101
            Dim ds As DataSet
            Dim emailList As String = ""
            ds = DBUtility.GetKisokAlertEmails(tempstoreID)
            If Not ds Is Nothing AndAlso ds.Tables.Count > 0 And ds.Tables(0).Rows.Count > 0 Then
                For Each dr In ds.Tables(0).Rows
                    emailList = dr("EmailList")
                Next
            End If
            Dim seperatedEmailList() As String = Split(emailList, ";")

            Dim counter As Integer = 0
            For Each email In seperatedEmailList
                emailBox.Text = emailBox.Text + email
                counter = counter + 1

            Next

        Catch ex As Exception
            Dim tempstoreID As Integer = 101
            LogUtility.LogMessage("Error in getting and parsing email list from database. " & ex.ToString, "I", tempstoreID)

        End Try


    End Sub
End Class

Upvotes: 0

Views: 68

Answers (1)

gritware
gritware

Reputation: 81

You keep overwriting the variable emailList. Therefore, when you attempt to split it, you will only get one email address.

Change:

emailList = dr("EmailList")

To:

emailList &= dr("EmailList").ToString & ";"

Upvotes: 1

Related Questions