Click to See Complete Forum and Search --> : ascx web control not appearing in aspx file


flynny1st
March 6th, 2008, 09:56 AM
can anyone please tell me what i'm doing wrong? this is the first time i;ve tried using these controls. It compiles ok and when i run it the other ascx file is have added appears but not the supplier_list.ascx. I have the following aspx file;


<%@ Page Language="VB" AutoEventWireup="True" Theme="Theme" Debug="true" %>
<%@ Register TagPrefix="Side_Frame" TagName="SupplierList" Src="supplier_list/supplier_list.ascx" %>
<%@ Register TagPrefix="Side_Frame" TagName="SearchPanel" Src="search_panel/search.ascx" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head id="Head1" runat="server">
</head>

<body>

<form runat=server>
<asp:Table Width="150px" runat="server">
<asp:TableRow>
<asp:TableCell>
HEREE
<Side_Frame:SupplierList id="supplier_list" runat="server" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<Side_Frame:SearchPanel id="search" runat="server" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>

</body>
</html>


the proble is the supplier_list.ascx is not appearing. the ascx file contains


<%@ Control Language="VB" AutoEventWireup="false" CodeFile="supplier_list.ascx.vb" Inherits="supplier_list" %>

<asp:DataGrid id="MyDataGrid" AutoGenerateColumns="false" runat="server">
<HeaderStyle CssClass="DataGridHeaderStyle"></HeaderStyle>
<Columns>
<asp:HyperLinkColumn
ItemStyle-CssClass ="ColumnItem"
HeaderText="Manufacturers"
DataNavigateUrlField="supplierID"
DataNavigateUrlFormatString="detailspage.aspx?id={0}"
DataTextField="name"
DataTextFormatString="{0:c}"
Target="_blank">
<ItemStyle CssClass="ColumnItem"></ItemStyle>
</asp:HyperLinkColumn>
</Columns>
</asp:DataGrid>


and the .vb file for this is



Imports System.Data
Imports System.Data.Odbc
Imports System.Data.SqlClient

Partial Class supplier_list
Inherits UserControl

Protected Shared Function getConnectionString() As String
'Pass the connectionstring in the appsettings of the web.config file
Return ConfigurationManager.AppSettings("Connectionweb")
End Function

Function CreateDataSource() As DataSet

Dim oQRY As String = "SELECT supplierID, name FROM suppliers"
Dim oDataAdapter As ODBCDataAdapter
Dim oDataSet As DataSet = New DataSet()

oDataAdapter = New ODBCDataAdapter(oQRY, getConnectionString())
oDataAdapter.Fill(oDataSet)

Return oDataSet

End Function

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

MyDataGrid.DataSource = CreateDataSource()
MyDataGrid.DataBind()

End Sub

End Class



many thanks,

Matt.

flynny1st
March 7th, 2008, 05:51 AM
Hi Guys,

sorted the problem it was here AutoEventWireup="false" all i needed to do was set this to true, this was stopping the page_load from firing automatically on the load.

thanks,

Matt.

Yeorwned
March 7th, 2008, 08:47 AM
Gotta love those one liners...I've spent hours trying to debug tens of thousands lines of code and in the end, it's always something stupid like that...something I purposely set for debugging.