troubleshooting Question

Need to know how to access a user control (.ascx) to build a StringBuilder() in another User Control

Avatar of westdh
westdhFlag for United States of America asked on
ASP.NETMicrosoft ApplicationsMicrosoft Development
8 Comments1 Solution382 ViewsLast Modified:
Here is some data on my compile error ->
so here is some more data on this line that is giving me an error located in register.ascx
 --> For Each dg As DataList In ctlAttendees.grdAttendees.Rows

Error#           'i2Integration.Modules.EventReg.CustomControls.AttendeeList.Protected WithEvents grdAttendees As System.Web.UI.WebControls.DataGrid' is not accessible in this context because it is 'Protected'.      C:\Documents and Settings\Dennis West\Local Settings\Temp\VWDWebCache\cmaanorcalevents.com\DesktopModules\i2Integration - Events\user\Register.ascx      

this is my -> Register.ascx User control
====================================================
<%@ Control Language="vb" Codebehind="Register.ascx.vb" Inherits="i2Integration.Modules.EventReg.Register"
    AutoEventWireup="false" Explicit="true" %>
<%@ Register TagPrefix="events" TagName="EventDetails" Src="../controls/EventDetails.ascx" %>
<%@ Register TagPrefix="events" TagName="AttendeeList" Src="../controls/AttendeeList.ascx" %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.WebControls.WebParts" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Net.Mail" %>
<%@ Import Namespace="System.Web.UI.Control" %>
<%@ Import Namespace="System.Net.Mail" %>

   <script runat="server" language="vb">
       
     Protected Sub EmailRegAttendeeNotices_Click(ByVal sender As Object, ByVal e As EventArgs)

             Dim sb As New StringBuilder()
             Dim x As UserControl = TryCast(FindControl("AttendeeList"), UserControl)
 error->    For Each dr As DataRow In ctlAttendees.grdAttendees.Rows
                sb.Append(ctlAttendees.grdAttendees.DataKeys(dr.RowIndex)              ("strBadgeName").ToString())
                sb.Append(",")
            Next
           
           If sb.ToString() <> "" Then
               'Response.Write(sb.ToString())
               Dim msg As New MailMessage("dennis@xxxxxxxxxxxx.com", sb.ToString())
               msg.Subject = "test"  'txtEmailSubject.Value
               msg.Body = "test" 'txtArea.Value

               Dim sc As New SmtpClient("smtp.xxxxxx.com", 25)
               sc.Credentials = New Net.NetworkCredential("dxxxx@dianewestdesign.com", "xxxxxxxxxx")
               sc.EnableSsl = False
               Try
                   sc.Send(msg)
                   Response.Write("<B>Email Has been sent successfully.</B>")
               Catch ex As Exception
                   Response.Write(ex.Message)
               End Try
           End If

       End Sub
       
   </script>

<asp:Label ID="lblError" runat="server" CssClass="NormalRed" EnableViewState="false"
    Visible="false" />
<asp:Panel ID="pnlMain" runat="server">
    <events:EventDetails id="ctlEvent" runat="server" ShowDetails="false" ShowDiscount="true" />
    <br />
    &nbsp; * If you are registering and today&#39;s date is within 3 days of the event date,
    add a $10.00 late fee.<br />
    &nbsp;&nbsp;&nbsp;&nbsp; Please select the appropriate member or non-member late Fee.<br />
    <table border="0" cellspacing="0" cellpadding="2" summary="Layout design table."
        id="tblAddAttendee" runat="server">
        <tr class="SubHead">

            <td>Attendee Name<br />
                First & Last Name:</td>

            <td>
                Attendee Email:</td>

            <td>
                Attendee Type and Cost:</td>

            <td>
                &nbsp;</td>

        </tr>
        <tr>

            <td>
                <asp:TextBox ID="txtAddUserTypeName" runat="server" CssClass="NormalTextbox" EnableViewState="False" />
            </td>

            <td>
                <asp:TextBox ID="txtAddUserTypeBadgeName" runat="server" CssClass="NormalTextbox"
                    EnableViewState="False" />
            </td>

            <td>
                <asp:DropDownList ID="lstUserTypes" runat="server" CssClass="NormalTextbox" EnableViewState="False" />
            </td>

            <td>
                <asp:Button ID="cmdAddUserType" runat="server" Text="Add Attendee(s)" EnableViewState="False"
                    CssClass="CommandButton" ValidationGroup="EventRegAttendee" />
            </td>

        </tr>
           
    </table>
             
    <font class="SubHead">
    <br />
    Attendees:</font>
    <br />
    <events:AttendeeList ID="ctlAttendees" runat="server" />
    <br />
    <asp:Label ID="lblAttendeeLimitReached" runat="server" CssClass="SubHead"
        resourcekey="AttendeeLimitReached" Visible="false"></asp:Label>
    <asp:Label ID="lblAttendeesLeftMessage" runat="server" CssClass="SubHead"></asp:Label>
    <asp:Button ID="Button1" runat="server" CssClass="CommandButton"
        EnableViewState="False" Text="Email event notices to registered attendees"
        ValidationGroup="EventRegAttendee" Width="269px"  OnClick="EmailRegAttendeeNotices()" />
    <br />
             
    <br />
    <font class="SubHead">
        <label for='<%= txtNeeds.ClientID %>'>
            Special Needs:</label>
    </font>
    <br />
    <asp:TextBox ID="txtNeeds" runat="server" Height="100" Width="600" TextMode="MultiLine" />
    <br />
    <font class="SubHead">
        <label for='<%= txtNotes.ClientID %>'>
            Comments:</label>
    </font>
    <br />
    <asp:TextBox ID="txtNotes" runat="server" Height="100" Width="600" TextMode="MultiLine" />
    <br />
    <font class="SubHead">
        <label for='<%= radPayMethod.ClientID %>_0'>
            Payment Method:</label></font><asp:RadioButtonList ID="radPayMethod" runat="server" AutoPostBack="False" RepeatDirection="Horizontal"
        CssClass="Normal" />
    <asp:Label ID="lblPayLaterNote" runat="server" CssClass="Normal" EnableViewState="False" />
    <br />
    <asp:Label ID="lblDonation" runat="server" resourcekey="DonationLabel" CssClass="SubHead"></asp:Label>
    <asp:TextBox ID="txtDonation" runat="server"></asp:TextBox>
    <asp:Label ID="lblDonationMessage" runat="server" resourcekey="DonationMessageLabel"
        CssClass="SubHead"></asp:Label>
    <asp:RegularExpressionValidator ID="valDonation" runat="server" resourcekey="DonationValidator"
        ControlToValidate="txtDonation" ValidationExpression="^\d+(?:\.\d{0,2})?$"></asp:RegularExpressionValidator>
    <br />
    <br />
</asp:Panel>
<asp:HyperLink class="CommandButton CancelButton" ID="lnkCancel" runat="server" BorderStyle="none"
    Text="Cancel" EnableViewState="False" />
<asp:LinkButton class="CommandButton SubmitButton" ID="cmdSubmit" runat="server" BorderStyle="none"
    Text="Next" CausesValidation="False" EnableViewState="False" />
   


this is my attendee control:
===============================
<%@ Control Language="vb" Codebehind="AttendeeList.ascx.vb" Inherits="i2Integration.Modules.EventReg.CustomControls.AttendeeList"
    AutoEventWireup="false" Explicit="true" %>
<asp:Label ID="lblNoRecords" runat="server" resourcekey="NoAttendeesMessage" CssClass="Normal"
    EnableViewState="False" Visible="False" Text="No attendees found."></asp:Label><br />
   
<asp:DataGrid ID="grdAttendees" runat="server" summary="Attendees design table."
    CellPadding="4" CellSpacing="0" AllowPaging="False" AllowSorting="False" AutoGenerateColumns="False"
    ShowHeader="True" ShowFooter="True" HeaderStyle-CssClass="SubHead" ItemStyle-CssClass="Normal"
    FooterStyle-CssClass="SubHead" FooterStyle-HorizontalAlign="Right" >
    <Columns>
        <asp:BoundColumn DataField="intRegistrationUserID" HeaderText="IDColumn" FooterText=""
            Visible="false" ReadOnly="True" />
        <asp:BoundColumn DataField="strRegistrationUserName" HeaderText="NameColumn" FooterText="" />
        <asp:BoundColumn DataField="strBadgeName" HeaderText="NameOnBadgeColumn" FooterText="" />
        <asp:BoundColumn DataField="strUserTypeName" HeaderText="TypeColumn" FooterText="TOTAL:"
            ReadOnly="True" />
        <asp:BoundColumn DataField="fltRegistrationUserCost" HeaderText="CostColumn" ReadOnly="True"
            DataFormatString="{0:$#,##0.00}" ItemStyle-HorizontalAlign="Right" FooterText="" />
        <asp:ButtonColumn ButtonType="LinkButton" CommandName="remove" HeaderText="RemoveColumn"
            Text="[Remove]" />
    </Columns>
</asp:DataGrid>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 8 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros