Wrox Programmer Forums
|
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2009, 12:43 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default Loading Controls Method

I am trying to load a drop down list from an existing table. I am using the List object I created for the table.

I need to know if there is a way to provide additional filtering when loading the control, the table itself has 2 important fields to me.

One field is called "Type" and is more or less a filter field the second field is called "Descsription"

I need to have the drop down list to display everything from Description where Type equals 4. I can easily do this with a standalone datasource but would like to stay within design flow of the Framework.

Below is what I have used thus far but it does not filter.

Code:
AECodeEOList aeCodes = newAECodeEOList();
aeCodes.Load();
ddlPhysicianContacted.DataSource = aeCodes;
ddlPhysicianContacted.DataTextField = "description";
ddlPhysicianContacted.DataValueField = "type";
ddlPhysicianContacted.DataBind();
Thanks
 
Old May 19th, 2009, 12:56 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

At a glance (I haven't had a chance to look at the code for this stuff from the book for a few weeks, so I'm going off memory here), could you do the filtering in the Load() method?

I'll see if I can look at the book's code later today and come up with something more helpful :)

Tim
 
Old May 19th, 2009, 01:51 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Ok....had a chance to reaquaint myself with the code. Here's an idea you might want to try:

If you don't already have a stored procedure that can return a filtered result set, create one. For purposes of your question, let's assume you have one called AECodeSelectByType, which takes one parameter (@Type INT).

Ensure you add this stored procedure (AECodeSelectByType) to the .dbml file, and the corresponding DAL class (AECodeData?).

Code:
public class AECodeData : ENTBaseDat<AECode>
{
 
     // other methods
 
     protected override List<AECode> SelectByType(int codeType)
     {
          // code to call SP goes here
     }
 
     // remaining methods
}
In the BLL class AECodeEOList, add an overloaded Load() method.

Code:
[Serializable()]
public class AECodeEOList : ENTBaseEOList<AECodeEO>
{
 
     // other methods
 
     public void Load(int codeType)
     {
          LoadFromList(new AECodeData().SelectByType(codeType));
     }
 
     // remaining methods
}
The LoadFromList will populate the List<T> with all records that have a Type = 4 (or whatever you specify.

Then your UI code would be pretty much unchanged:

Code:
AECodeEOList aeCodes = newAECodeEOList();
aeCodes.Load(4);
ddlPhysicianContacted.DataSource = aeCodes;
ddlPhysicianContacted.DataTextField = "description";
ddlPhysicianContacted.DataValueField = "type";
ddlPhysicianContacted.DataBind();
Hopefully this will get you headed in the right direction, and I think it stays true to the framework. The only thing I'm not entirely sure on is if it's a violation of OOP principles to provide an overloaded method on an overriden method...

Tim
 
Old May 19th, 2009, 05:30 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

Tim, thanks for the reply, I have tried what you posted and although I think you are for sure on the right track, I was unable to get it working quickly. I did find a few stored procedures that behave in a similar manner to what I need in the PTORequest area from the sample project. I will grab grab the book and look at what took place to get there.

What had me at a stopping point, is intellisense could not find my SelectByType() method. I think this has to also be added to the code behind file of the .dbml, I really didnt get a chance to dig too deep into it today.

When I figure it out I will post back here with what I had to do, but I think what you posted has put me on the right track.

Thanks

DJ
 
Old May 26th, 2009, 05:08 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

Sorry for the laspe in posting back to this topic. Sometimes there is no telling what I will be doing at the job. Anyway, I found that the easiest way for me to go about this was via the stored procedure. I had to implement this into the dbml file but had the hardest time doing it manually by hand.

I really wish there was an easier way to work with this file. Many times I have tried to modify it and ended up removing my tables, stored procedures, DAL and BLL files and doing it over for whatever tables I need to add/modify. Does anyone else experience this, I hope MS add some extended functionality for dbml files in the next version on VS.

Thanks
 
Old May 28th, 2009, 02:13 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

That's what makes our field so fun - you never know what you'll be doing (I'm a .NET developer and I've been doing 95% Clipper programming for the last 3 or 4 weeks).

I've had the same issue with the dbml file when I change something. It'd be nice if MS adds refresh/update functionality to this in the next release.

I'd also like to be able to open the XML source for the file in Visual Studio. Sometimes I make one minor change, and it'd be easier to make the change in the XML file than to delete stuff and add it back.





Similar Threads
Thread Thread Starter Forum Replies Last Post
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
Need urgent help loading user controls at runtime rpeters83 ASP.NET 2.0 Professional 7 September 3rd, 2006 10:17 AM
aspx page not loading!!!! Method called too soon dba123 C# 0 August 6th, 2006 11:18 PM
Loading and Destroying web user controls into a pa see07 ASP.NET 1.x and 2.0 Application Design 5 February 4th, 2005 04:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.