I've created a user control page containing a third-party grid. The code works fine when the grid is embedded in a regular ASP.NET page. However, errors are being thrown once I add the same grid as an .ascx control to a page. This is the first time I've created a user control so I'm hoping there's something really obvious wrong.
.ascx Code-behind:
.ascx:
.aspx:
.ascx Code-behind:
Code:
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.Page
Imports System.Data
Imports System.Data.SqlClient
Imports Obout.Grid
Partial Class Goals
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not (IsPostBack) Then
GetGoals(sender, e)
End If
End Sub
Sub GetGoals(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conn As New SqlConnection("Server=WACBLSQL03;Database=WACommissions;User ID=WACommWeb;Password=123;Trusted_Connection=False")
Dim cmd As New SqlCommand("stp_GetAgentGoals", conn)
cmd.CommandType = CommandType.StoredProcedure
Try
conn.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader
Trace.Warn(reader.HasRows)
grdGoals.DataSource = reader
grdGoals.DataBind()
reader.Close()
Catch ex As Exception
Trace.Warn(ex.ToString)
Finally
conn.Dispose()
End Try
End Sub
.ascx:
Code:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Goals.ascx.vb" Inherits="Goals" %>
<%@ import namespace="Obout.Grid" %>
<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="obout" %>
<obout:Grid runat="server" id="grdGoals" FolderStyle="/obout/style_8" AutoGenerateColumns="False"
EnableRecordHover="true" AllowAddingRecords="False" AllowRecordSelection="False" CallbackMode="true" Serialize="true"
OnRebind="GetGoals" OnUpdateCommand="UpdateGoals" AllowMultiRecordSelection="False" AllowGrouping="True" GroupBy="name,SDTE" ShowCollapsedGroups="True" PageSize="100">
<Columns>
<obout:Column Width="100px" HeaderAlign="center" DataField="name" ReadOnly="True" HeaderText="Name" Index="0"></obout:Column>
<obout:Column Width="0px" HeaderAlign="center" Visible="False" DataField="HRID" ReadOnly="True" HeaderText="HRID" Index="1"></obout:Column>
<obout:Column Width="80px" HeaderAlign="center" DataField="SDTE" ReadOnly="True" HeaderText="Start Date" Index="2"></obout:Column>
<obout:Column Width="80px" HeaderAlign="center" DataField="EDTE" ReadOnly="True" HeaderText="End Date" Index="3"></obout:Column>
<obout:Column Width="95px" HeaderAlign="center" DataField="GTOP" ReadOnly="True" HeaderText="GTOP" Index="4"></obout:Column>
<obout:Column Width="60px" HeaderAlign="center" DataField="VID" HeaderText="VID" Index="5"></obout:Column>
<obout:Column Width="60px" HeaderAlign="center" DataField="LIM" HeaderText="LIM" Index="6"></obout:Column>
<obout:Column Width="60px" HeaderAlign="center" DataField="BAS" HeaderText="BAS" Index="7"></obout:Column>
<obout:Column Width="60px" HeaderAlign="center" DataField="ENH" HeaderText="ENH" Index="8"></obout:Column>
</Columns>
</obout:Grid>
.aspx:
Code:
<%@ Page Language="VB" MasterPageFile="~/_Lib/Site.master" StyleSheetTheme="Site" AutoEventWireup="false" CodeFile="Home.aspx.vb" Inherits="Home" title="Home" %>
<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="obout" %>
<%@ Register Src="Goals.ascx" TagName="Goals" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<uc1:Goals id="grdGoals" runat="server"></uc1:Goals>
</asp:Content>