• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Check Box Selections--Form Email Trouble

I have a form in asp.net VB which emails the results.
I am having trouble getting the selections checked in a checkbox to appear in the email.
I don't care how I accomplish this--checkboxes or listboxes with multi selects, but I can't seem to
get it to work.


Here's the checkbox
  <asp:checkboxlist id="ReasonForRequest" runat="server">
      <asp:listitem id="Annexation" runat="server" value="Annexation />
      <asp:listitem id="Consolidation" runat="server" value="Consolidation" />
         </asp:checkboxlist>
   

Here's the coding to create the mail contents.
Everything else--textboxes and drop downs have worked...
   
  '(1) Create the MailMessage instance
         Dim mm As New MailMessage(UsersEmail.Text, ToAddress)
         mm.CC.Add(new MailAddress(UsersEmail.Text))

        Dim sMsg as String
       'example of text box --this works OK
        sMsg+="Last Name : " & lastName.Text & vbcrlf

     ' here I am trying to put the check checkedboxlist items in to a string
       sMsg+="ReasonForRequest : " & ReasonForRequest.Items[0].Text & vbcrlf
       sMsg+="ReasonForRequest : " & ReasonForRequest.Items[1].Text & vbcrlf


This will cause me to get an error
BC30452: Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.ListItemCollection'


How can I get the checkbox selections to appear in the mail?
0
LT1415
Asked:
LT1415
  • 4
  • 2
1 Solution
 
sm394Commented:
try that
sMsg=sMsg & "ReasonForRequest : " & ReasonForRequest.Items[0].Text & vbcrlf
sMsg=sMsg & "ReasonForRequest : " & ReasonForRequest.Items[1].Text & vbcrlf
0
 
LT1415Author Commented:
BC30452: Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.ListItemCollection'

Thanks, but I still am receiving the same error -- it doesn't like the & 
0
 
sm394Commented:
this should do
sMsg = sMsg & "ReasonForRequest : " & ReasonForRequest.Items(0).Text & vbCrLf
        sMsg = sMsg & "ReasonForRequest : " & ReasonForRequest.Items(1).Text & vbCrLf
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sm394Commented:
also remove id=" " runat="server"   from ListItem like below

<asp:CheckBoxList ID="ReasonForRequest" runat="server">
            <asp:ListItem Value="Annexation">
            </asp:ListItem>
            <asp:ListItem Value="Consolidation">
            </asp:ListItem>
        </asp:CheckBoxList>
0
 
LT1415Author Commented:
Bingo!
That worked thanks so much
0
 
sm394Commented:
u welcome :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now