Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: UserControl Problems


Message #1 by "Rick Delorme" <rick@p...> on Thu, 8 Nov 2001 12:59:57 -0500
Change the accessor specification for the class members from Protected to 
Public!

Dave Razzetti

> Hi,
> I have a user control that consists of 3 datagrids. I have exposed
> properties that allow me to set up each data grid's datasource. However,
> when I set the property, exceptions are flying saying that there is a 
null
> reference. My question is, why is the DataGrids in the UserControl not
> instantiated in the Code Behind?
> 
> 
> Here is the aspx code (the codebehind is below it):
> 
>  <%@ Control Language="vb" AutoEventWireup="false"
> Codebehind="ConfigHasMembers.ascx.vb" 
Inherits="CyberACD4.ConfigHasMembers"
> %>
>  <asp:table runat=server ID="Table1">
>   <asp:tablerow >
>    <asp:Tablecell ColumnSpan=2>
>     <asp:DataGrid id="Group" runat=server></asp:DataGrid>
>    </asp:TableCell>
>   </asp:tablerow>
>   <asp:TableRow>
>    <asp:TableCell>
>     <asp:DataGrid ID="AvailableMembers" Runat=server></asp:DataGrid>
>    </asp:TableCell>
>    <asp:TableCell>
>     <asp:DataGrid ID="SelectedMembers" Runat=server></asp:DataGrid>
>    </asp:TableCell>
>   </asp:TableRow>
> </asp:table>
> 
> Codebehind:
> Public Class ConfigHasMembers
> 
> Inherits System.Web.UI.UserControl
> 
> Protected WithEvents Table1 As System.Web.UI.WebControls.Table
> 
> Protected WithEvents Group As System.Web.UI.WebControls.DataGrid
> 
> Protected WithEvents AvailableMembers As 
System.Web.UI.WebControls.DataGrid
> 
> Protected WithEvents SelectedMembers As 
System.Web.UI.WebControls.DataGrid
> 
> End Sub
> 
> 'properties
> 
> Public Property GridGroupDataSource() As DataTable
> 
> Get
> 
> Return Group.DataSource
> 
> End Get
> 
> Set(ByVal Value As DataTable)
> 
> Group.DataSource = Value.DefaultView
> 
> End Set
> 
> End Property
> 
> 
> 
> Thanks,
> 
> Rick.
> 
> 
> 
> 
> 
> 
> 
> 
> 

  Return to Index