Results 1 to 7 of 7

Thread: Passing Dataset to User Web Control

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    59

    Passing Dataset to User Web Control

    I have a web user control that has the following properties

    Code:
    Dim ds As DataSet
    Dim EditPage As String
        'Properties
        Public Property PropDS() As DataSet
            Get
                Return Me.ds
            End Get
            Set(ByVal Value As DataSet)
                ds = Value
            End Set
        End Property
        Public Property PropEditPage() As String
            Get
                Return EditPage
            End Get
            Set(ByVal Value As String)
                EditPage = Value
            End Set
        End Property
    But when I try and access the properties from an ASPX page. It says the control is not declared. Here is the Source:

    Code:
    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="TestDgrid.aspx.vb" Inherits="TestDgrid" title="Untitled Page" %>
    
    <%@ Register Src="Dgrid.ascx" TagName="Dgrid" TagPrefix="uc1" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">         
    
    <uc1:Dgrid id="Dgrid1" name="Dgrid1" runat="server">        
    </uc1:Dgrid>  
    
    </asp:Content>
    so if I try and do something like this it errors out:

    Code:
    Dim ds as dataset = new Dataset
    ds = Getdataset("Select * from Product") 
    Dgrid1.PropDS = ds
    Any Help would be appreciated!!! Thanks!

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Passing Dataset to User Web Control

    Probably because the Src to the Dgrid isn't right. Try giving it a virtualized path like

    ~/usercontrols/Dgrid1.ascx

    I believe it's not able to find the web user control you created due to the simplistic/relative path you're using.

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    59

    Re: Passing Dataset to User Web Control

    Ok, I created a folder called UserControls and changed the page to the following:

    Code:
    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="TestDgrid.aspx.vb" Inherits="TestDgrid" title="Untitled Page" %>
    
    <%@ Register Src="~/UserControls/Dgrid.ascx" TagName="Dgrid" TagPrefix="uc1" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <uc1:Dgrid id="Dgrid1" runat="server">
        </uc1:Dgrid>
        
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" />
      
    
    </asp:Content>
    Still Doesn't work. The "Dgrid" is underlined in the "<uc1grid " opening tag and the error says: "Element Dgrid is not a Known Element"

    So I think you are right, its not seeing my usercontrol. Is there something on the control side that makes it public?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Passing Dataset to User Web Control

    Show the code for your ASCX, markup as well as codebehind.

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Passing Dataset to User Web Control

    Oh, another thing you could try is going into designer view for your main page and then dragging the ASCX from Solution Explorer into your main page and see if it shows up properly in intellisense after that.

  6. #6

    Thread Starter
    Member
    Join Date
    Oct 2006
    Posts
    59

    Re: Passing Dataset to User Web Control

    Thanks for the help....
    But it turned out that there was some errors in my code.
    Funny thing is that when you have errors in a user control and drag it onto a form, instead of telling you that there is an error, it just doesn't recognize the control. If you click on the control and then try and view the properties, it will be empty and all you will see is "<Controlname>" .

    So i copied the control code to an ASPX page and cleaned up the errors then copied it back to the user control and everything works like it supposed to.


    Thanks Again!

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Passing Dataset to User Web Control

    Glad to have helped in a minute way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width