471,579 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,579 software developers and data experts.

GridView - ObjectDataSource NOT retrieving records

Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView control by
using the ObjectDataSource. This is our first OOP web application, and we
have no tables. Right now we are simply working with objects in memory.

So, it appears as though Microsoft requires that our datamapper classes
reside inside a folder called "App_Code", and NO WHERE ELSE.

So, has anyone successfully been able to place their datamappers in a
location other than "App_Code", and actually retrieve records from a
datamapper class?

TIA, Randy
Jan 8 '07 #1
5 2499
Hi Phillip,
I rally appreciate your help. I like your sample "Dropdownlist within a
GridView", but I do have a few questions about your ObjectDataSource.

Here is the code I'm interested in:
<asp:ObjectDataSource ID="odsProducts" runat="server"
SelectMethod="ProductByID"
TypeName="WEBSWAPP_BLL.Demos"
DataObjectTypeName="WEBSWAPP_BLL.clsProduct">
<SelectParameters>
<asp:ControlParameter
ControlID="ddlProducts" Name="productID" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
1) I presume that "WEBSWAPP_BLL" is a DLL, right? Where is it located in
your folder structure?
2) I see that you are using "TypeName". I presume that "Demos" is the class
inside your "WEBSWAPP_BLL" DLL, right?
3) Did you have to add any specific entries into the web.config file to get
it to work?
4) I haven't seen your "default.aspx.cs" code, but do you have this
reference: "using WEBSWAPP_BLL;" (C#)?

Many thanks, Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:DA**********************************@microsof t.com...
Hello Randy,

You can compile your domain layer into a separate assembly and add a
reference to it in your project (all the demos on my website are build
using
this strategy) or you can also download the "Visual Studio 2005 Web
Application Projects" to build applications in the same way as you used to
VS2003 where you do not have to put your datamappers in the App_Code
folder
http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:
>Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView control by
using the ObjectDataSource. This is our first OOP web application, and
we
have no tables. Right now we are simply working with objects in memory.

So, it appears as though Microsoft requires that our datamapper classes
reside inside a folder called "App_Code", and NO WHERE ELSE.

So, has anyone successfully been able to place their datamappers in a
location other than "App_Code", and actually retrieve records from a
datamapper class?

TIA, Randy

Jan 9 '07 #2
Hi,
Well, I've changed my ObjectDataSource to match your examples, but I am
still not getting any data. I wonder if you can post the code for
"default.aspx.cs" (within "Dropdownlist within a GridView". I'm
particularly interested in seeing how you go about doing the "databind",
which may be my problem.
Many, many thanks!!! Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:34**********************************@microsof t.com...
Hello Randy,

For the purpose of my website where the demos do not have real business
logic (it is just a presentation logic built on top of a dataset),
WEBSWAPP_BLL is just a domain layer with a dataset.

The DAL in that demos website is a VS generated dataset named Samples.xsd
(which is not listed on the website). Its structure (a typed dataset of a
collection of datatables) is not necessary to understanding the demos that
I
placed to demonstrate the ASP.NET server controls features. I load it
into
the application cache to allow the users to write to the dataset in cache
but
then I do not persist their entries on the data store.

The class named WEBSWAPP_BLL.Demos is the compiled into a separate
assembly
from another project (class library), which is not within the folders
structure of the web application. I only add the compiled assembly (dll
file) to the bin folder on the web application (by adding a reference to
the
class library project into my web application project).

So to answer to your questions:
1- A separate class library project compiled into a dll that is copied to
the bin folder of the website
2- Yes
3- No.
4- No.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:
>Hi Phillip,
I rally appreciate your help. I like your sample "Dropdownlist within a
GridView", but I do have a few questions about your ObjectDataSource.

Here is the code I'm interested in:
<asp:ObjectDataSource ID="odsProducts" runat="server"
SelectMethod="ProductByID"
TypeName="WEBSWAPP_BLL.Demos"
DataObjectTypeName="WEBSWAPP_BLL.clsProduct">
<SelectParameters>
<asp:ControlParameter
ControlID="ddlProducts" Name="productID" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
1) I presume that "WEBSWAPP_BLL" is a DLL, right? Where is it located in
your folder structure?
2) I see that you are using "TypeName". I presume that "Demos" is the
class
inside your "WEBSWAPP_BLL" DLL, right?
3) Did you have to add any specific entries into the web.config file to
get
it to work?
4) I haven't seen your "default.aspx.cs" code, but do you have this
reference: "using WEBSWAPP_BLL;" (C#)?

Many thanks, Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:DA**********************************@microso ft.com...
Hello Randy,

You can compile your domain layer into a separate assembly and add a
reference to it in your project (all the demos on my website are build
using
this strategy) or you can also download the "Visual Studio 2005 Web
Application Projects" to build applications in the same way as you used
to
VS2003 where you do not have to put your datamappers in the App_Code
folder
http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:

Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView control
by
using the ObjectDataSource. This is our first OOP web application,
and
we
have no tables. Right now we are simply working with objects in
memory.

So, it appears as though Microsoft requires that our datamapper
classes
reside inside a folder called "App_Code", and NO WHERE ELSE.

So, has anyone successfully been able to place their datamappers in a
location other than "App_Code", and actually retrieve records from a
datamapper class?

TIA, Randy



Jan 10 '07 #3
So,
Do I understand that you didn't need to do any sort of "databind"? I had
this code in my Page_Load event:
gvMaterialRates.DataSource = ObjectDataSource1;

gvMaterialRates.DataBind();

I've tried it several different ways:
1) As above
2) With the "DataSource" line commented out, and the other line active.
3) With the "DataBind" line commented out, and the other line active.
4) With both lines commented out.

I'll try the debug route and see what happens.

Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:17**********************************@microsof t.com...
Have you tried stepping in debug mode with break points within the BLL &
DAL
to see if the web interface is calling the methods of your object library?
It might be an issue of the structure of your namespaces. In my demos I
put
the fully qualified name of the class starting from the root namespace,
e.g.
WEBSWAPP_BLL.Demos is the fully qualified path.

In your case it might be something like MyCompany.Modules.App1.className.
Make sure you put the fully qualified path in the values for TypeName and
DataObjectTypeName properties of the ObjectDataSource. Then set break
points
within those methods to debug in VS.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:
>Hi,
Well, I've changed my ObjectDataSource to match your examples, but I am
still not getting any data. I wonder if you can post the code for
"default.aspx.cs" (within "Dropdownlist within a GridView". I'm
particularly interested in seeing how you go about doing the "databind",
which may be my problem.
Many, many thanks!!! Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:34**********************************@microso ft.com...
Hello Randy,

For the purpose of my website where the demos do not have real business
logic (it is just a presentation logic built on top of a dataset),
WEBSWAPP_BLL is just a domain layer with a dataset.

The DAL in that demos website is a VS generated dataset named
Samples.xsd
(which is not listed on the website). Its structure (a typed dataset
of a
collection of datatables) is not necessary to understanding the demos
that
I
placed to demonstrate the ASP.NET server controls features. I load it
into
the application cache to allow the users to write to the dataset in
cache
but
then I do not persist their entries on the data store.

The class named WEBSWAPP_BLL.Demos is the compiled into a separate
assembly
from another project (class library), which is not within the folders
structure of the web application. I only add the compiled assembly
(dll
file) to the bin folder on the web application (by adding a reference
to
the
class library project into my web application project).

So to answer to your questions:
1- A separate class library project compiled into a dll that is copied
to
the bin folder of the website
2- Yes
3- No.
4- No.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:

Hi Phillip,
I rally appreciate your help. I like your sample "Dropdownlist within
a
GridView", but I do have a few questions about your ObjectDataSource.

Here is the code I'm interested in:
<asp:ObjectDataSource ID="odsProducts" runat="server"
SelectMethod="ProductByID"
TypeName="WEBSWAPP_BLL.Demos"
DataObjectTypeName="WEBSWAPP_BLL.clsProduct">
<SelectParameters>
<asp:ControlParameter
ControlID="ddlProducts" Name="productID" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
1) I presume that "WEBSWAPP_BLL" is a DLL, right? Where is it located
in
your folder structure?
2) I see that you are using "TypeName". I presume that "Demos" is the
class
inside your "WEBSWAPP_BLL" DLL, right?
3) Did you have to add any specific entries into the web.config file
to
get
it to work?
4) I haven't seen your "default.aspx.cs" code, but do you have this
reference: "using WEBSWAPP_BLL;" (C#)?

Many thanks, Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:DA**********************************@microso ft.com...
Hello Randy,

You can compile your domain layer into a separate assembly and add a
reference to it in your project (all the demos on my website are
build
using
this strategy) or you can also download the "Visual Studio 2005 Web
Application Projects" to build applications in the same way as you
used
to
VS2003 where you do not have to put your datamappers in the App_Code
folder
http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:

Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView
control
by
using the ObjectDataSource. This is our first OOP web application,
and
we
have no tables. Right now we are simply working with objects in
memory.

So, it appears as though Microsoft requires that our datamapper
classes
reside inside a folder called "App_Code", and NO WHERE ELSE.

So, has anyone successfully been able to place their datamappers in
a
location other than "App_Code", and actually retrieve records from
a
datamapper class?

TIA, Randy




Jan 10 '07 #4
UPDATE:
I debugged the "FetchAllRates" and found that it was showing a count of ZERO
records, even though I have 3 rows in the object. It then dawned on me that
our consultant switched us over to ApplicationManager.cs. This piece of
code actually returns a count of 3, whereas my direct code retrieves ZERO.
lblRows.Text =
ApplicationManager.MaterialRateDM.FetchAllRates(). Count.ToString();
//returns 3 rows

Here's the code I was using for my ObjectDataSource:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"

SelectMethod="FetchAllRates" TypeName="GWO.MaterialRateDataMapper"
EnablePaging="false">

</asp:ObjectDataSource>

If I replace the "GWO.MaterialRateDataMapper" with
"ApplicationManager.MaterialRateDM", I get an error indicating that
"FetchAllRates" could not be found.
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:CC**********************************@microsof t.com...
That's correct. The ObjectDataSource encapsulates the logic for
retrieving
the data and the GridView uses the value of the DataSourceID property to
locate the ObjectDataSource control within the page's controls hierarchy
and
automatically binds the data.

You can still use the programmatic approach if you wish, in which case you
would not need to place an ObjectDataSource on the page.

You can read further about the GridView:
http://msdn2.microsoft.com/en-gb/lib....gridview.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:
>So,
Do I understand that you didn't need to do any sort of "databind"? I had
this code in my Page_Load event:
gvMaterialRates.DataSource = ObjectDataSource1;

gvMaterialRates.DataBind();

I've tried it several different ways:
1) As above
2) With the "DataSource" line commented out, and the other line active.
3) With the "DataBind" line commented out, and the other line active.
4) With both lines commented out.

I'll try the debug route and see what happens.

Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:17**********************************@microso ft.com...
Have you tried stepping in debug mode with break points within the BLL
&
DAL
to see if the web interface is calling the methods of your object
library?
It might be an issue of the structure of your namespaces. In my demos I
put
the fully qualified name of the class starting from the root namespace,
e.g.
WEBSWAPP_BLL.Demos is the fully qualified path.

In your case it might be something like
MyCompany.Modules.App1.className.
Make sure you put the fully qualified path in the values for TypeName
and
DataObjectTypeName properties of the ObjectDataSource. Then set break
points
within those methods to debug in VS.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:

Hi,
Well, I've changed my ObjectDataSource to match your examples, but I
am
still not getting any data. I wonder if you can post the code for
"default.aspx.cs" (within "Dropdownlist within a GridView". I'm
particularly interested in seeing how you go about doing the
"databind",
which may be my problem.
Many, many thanks!!! Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:34**********************************@microso ft.com...
Hello Randy,

For the purpose of my website where the demos do not have real
business
logic (it is just a presentation logic built on top of a dataset),
WEBSWAPP_BLL is just a domain layer with a dataset.

The DAL in that demos website is a VS generated dataset named
Samples.xsd
(which is not listed on the website). Its structure (a typed
dataset
of a
collection of datatables) is not necessary to understanding the
demos
that
I
placed to demonstrate the ASP.NET server controls features. I load
it
into
the application cache to allow the users to write to the dataset in
cache
but
then I do not persist their entries on the data store.

The class named WEBSWAPP_BLL.Demos is the compiled into a separate
assembly
from another project (class library), which is not within the
folders
structure of the web application. I only add the compiled assembly
(dll
file) to the bin folder on the web application (by adding a
reference
to
the
class library project into my web application project).

So to answer to your questions:
1- A separate class library project compiled into a dll that is
copied
to
the bin folder of the website
2- Yes
3- No.
4- No.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:

Hi Phillip,
I rally appreciate your help. I like your sample "Dropdownlist
within
a
GridView", but I do have a few questions about your
ObjectDataSource.

Here is the code I'm interested in:
<asp:ObjectDataSource ID="odsProducts" runat="server"
SelectMethod="ProductByID"
TypeName="WEBSWAPP_BLL.Demos"
DataObjectTypeName="WEBSWAPP_BLL.clsProduct">
<SelectParameters>
<asp:ControlParameter
ControlID="ddlProducts" Name="productID"
PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
1) I presume that "WEBSWAPP_BLL" is a DLL, right? Where is it
located
in
your folder structure?
2) I see that you are using "TypeName". I presume that "Demos" is
the
class
inside your "WEBSWAPP_BLL" DLL, right?
3) Did you have to add any specific entries into the web.config
file
to
get
it to work?
4) I haven't seen your "default.aspx.cs" code, but do you have this
reference: "using WEBSWAPP_BLL;" (C#)?

Many thanks, Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:DA**********************************@microso ft.com...
Hello Randy,

You can compile your domain layer into a separate assembly and
add a
reference to it in your project (all the demos on my website are
build
using
this strategy) or you can also download the "Visual Studio 2005
Web
Application Projects" to build applications in the same way as
you
used
to
VS2003 where you do not have to put your datamappers in the
App_Code
folder
http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:

Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView
control
by
using the ObjectDataSource. This is our first OOP web
application,
and
we
have no tables. Right now we are simply working with objects in
memory.

So, it appears as though Microsoft requires that our datamapper
classes
reside inside a folder called "App_Code", and NO WHERE ELSE.

So, has anyone successfully been able to place their datamappers
in
a
location other than "App_Code", and actually retrieve records
from
a
datamapper class?

TIA, Randy





Jan 10 '07 #5
Have you tried stepping in debug mode with break points within the BLL & DAL
to see if the web interface is calling the methods of your object library?
It might be an issue of the structure of your namespaces. In my demos I put
the fully qualified name of the class starting from the root namespace, e.g.
WEBSWAPP_BLL.Demos is the fully qualified path.

In your case it might be something like MyCompany.Modules.App1.className.
Make sure you put the fully qualified path in the values for TypeName and
DataObjectTypeName properties of the ObjectDataSource. Then set break points
within those methods to debug in VS.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:
Hi,
Well, I've changed my ObjectDataSource to match your examples, but I am
still not getting any data. I wonder if you can post the code for
"default.aspx.cs" (within "Dropdownlist within a GridView". I'm
particularly interested in seeing how you go about doing the "databind",
which may be my problem.
Many, many thanks!!! Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:34**********************************@microsof t.com...
Hello Randy,

For the purpose of my website where the demos do not have real business
logic (it is just a presentation logic built on top of a dataset),
WEBSWAPP_BLL is just a domain layer with a dataset.

The DAL in that demos website is a VS generated dataset named Samples.xsd
(which is not listed on the website). Its structure (a typed dataset of a
collection of datatables) is not necessary to understanding the demos that
I
placed to demonstrate the ASP.NET server controls features. I load it
into
the application cache to allow the users to write to the dataset in cache
but
then I do not persist their entries on the data store.

The class named WEBSWAPP_BLL.Demos is the compiled into a separate
assembly
from another project (class library), which is not within the folders
structure of the web application. I only add the compiled assembly (dll
file) to the bin folder on the web application (by adding a reference to
the
class library project into my web application project).

So to answer to your questions:
1- A separate class library project compiled into a dll that is copied to
the bin folder of the website
2- Yes
3- No.
4- No.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:
Hi Phillip,
I rally appreciate your help. I like your sample "Dropdownlist within a
GridView", but I do have a few questions about your ObjectDataSource.

Here is the code I'm interested in:
<asp:ObjectDataSource ID="odsProducts" runat="server"
SelectMethod="ProductByID"
TypeName="WEBSWAPP_BLL.Demos"
DataObjectTypeName="WEBSWAPP_BLL.clsProduct">
<SelectParameters>
<asp:ControlParameter
ControlID="ddlProducts" Name="productID" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
1) I presume that "WEBSWAPP_BLL" is a DLL, right? Where is it located in
your folder structure?
2) I see that you are using "TypeName". I presume that "Demos" is the
class
inside your "WEBSWAPP_BLL" DLL, right?
3) Did you have to add any specific entries into the web.config file to
get
it to work?
4) I haven't seen your "default.aspx.cs" code, but do you have this
reference: "using WEBSWAPP_BLL;" (C#)?

Many thanks, Randy
"Phillip Williams" <WE******@newsgroups.nospamwrote in message
news:DA**********************************@microsof t.com...
Hello Randy,

You can compile your domain layer into a separate assembly and add a
reference to it in your project (all the demos on my website are build
using
this strategy) or you can also download the "Visual Studio 2005 Web
Application Projects" to build applications in the same way as you used
to
VS2003 where you do not have to put your datamappers in the App_Code
folder
http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Randy Smith" wrote:

Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView control
by
using the ObjectDataSource. This is our first OOP web application,
and
we
have no tables. Right now we are simply working with objects in
memory.

So, it appears as though Microsoft requires that our datamapper
classes
reside inside a folder called "App_Code", and NO WHERE ELSE.

So, has anyone successfully been able to place their datamappers in a
location other than "App_Code", and actually retrieve records from a
datamapper class?

TIA, Randy



Jan 13 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Oleg Ogurok | last post: by
2 posts views Thread by Robert Smith jr. | last post: by
7 posts views Thread by Ken | last post: by
1 post views Thread by A_StClaire_ | last post: by
2 posts views Thread by OJ | last post: by
8 posts views Thread by Greg Lyles | last post: by
3 posts views Thread by Mike | last post: by
reply views Thread by =?Utf-8?B?RGVubmlzIE1jQ2FydGh5?= | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.