|
-
Nov 17th, 2008, 12:20 PM
#1
Thread Starter
Member
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!
-
Nov 17th, 2008, 04:03 PM
#2
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.
-
Nov 17th, 2008, 04:21 PM
#3
Thread Starter
Member
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 "<uc1 grid " 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?
-
Nov 18th, 2008, 08:24 AM
#4
Re: Passing Dataset to User Web Control
Show the code for your ASCX, markup as well as codebehind.
-
Nov 18th, 2008, 08:25 AM
#5
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.
-
Nov 18th, 2008, 09:42 AM
#6
Thread Starter
Member
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!
-
Nov 19th, 2008, 06:36 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|