Mitchel's Forums

Subject: looping through and arraylist in dnn
Prev Next
You are not authorized to post a reply.

AuthorMessages
CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 11:25 AM  

Ok. I'm very confused as to whats going on here.

I'm still a bit new to .Net and DNN, so please bear with me.

I'm developing a new module for DNN. I've been able to get everything working properly so far, but this part has baffled me for literally two days now.

I'm creating a vendor module for a client and in the vendor details page, I have 6 different checkboxes marking the 6 different locations the vendor could be attached to. In the db, I have a many-tomany table taht matches each possible location to its vendor and I'm running a sp to pull those according to the vendor's id number. Now, if this was classic asp, I woulda had it done in a matter of minutes because I have done this same thing many many times.

So what I need is for each cckbox, loop through the pulld data result and check the checkbox's value against that paticular record row.

Say something like this:

for i=0 to 5
   if the row value = the checkbox value, mark the checkbox as checked
next

No the loops is not problem, I just cn't figure out how to get the stinkin data set so I can loop through it. I have tried creating arraylists and generic lists, but everything I find says to do it like this:

 

KochAirVendorManagerController objLocations = newKochAirVendorManagerController();
KochAirVendorManagerInfo objLocationsInfo = objLocations.GetLocationsByVendor(vendorId);

 

 

ArrayList LocationsArray = newArrayList();while (objLocationsInfo.Read())
{
     LocationsArray.add(objLocationsInfo(
"FieldName"));
}

But everytime I do I get an error saying it doesn't contain a definition for 'read' and that I might be missing an assembly reference. Further investigations shows I probabaly AM missing the System.Data.SqlClient namespace. So I add it and I get an error saying that System.Data does not contain the SqlClient namespace, and I might be missing ANOTHER reference. So I investigate further and I find that I need to reference the System.Data.dll. BUT I ALREADY AM!!

What the heck am I doing wrong? Is there another way to do what I am wanting to do here? Datalists, datagrids and about any other control I can find don't seem to be the solution. I just need to step through data in some way but Ic an't seem to get it into a form that I can step through. I'm about to bust out the cassic asp and throw it n there to make it work!!!

PLEASE!

CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 11:28 AM  
wow. I can't type. sorry.
Mitchel SellersUser is Offline
Site Admin/Owner
Guru
Guru
Posts:5644

06/02/2008 11:41 AM  
Corey,

Can you send me the code for the controller class? Your return type from the controller should be a List<> of objects, rather than a single object, I would guess.

Also, how is the data formatted from the return?

-Mitchel Sellers
MCITP, MCPD, MCTS
Director of Development
IowaComputerGurus Inc.

View Mitchel Sellers's profile on LinkedIn

3Essentials is my recommended Shared Hosting Provider

This site is hosted on a VPS from HostMySIte.com

Mosso is my recommended cloud computing provider. Use reference code REF-ICG to get $100 off your second month!

To get Guaranteed DNN Support check out our affordable DNN Technical Support Programs
CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 11:50 AM  

Yes, List<> was one of the problems I was having also. I tried it in the controller class and coudn't get it to work either...

Here are my 3 different attempts. I've looked everywhere for better info and its really done nothing but confuse the hell out of me.

 

 

 

 

publicKochAirVendorManagerInfo GetLocationsByVendor(int vendorId)
{
return (KochAirVendorManagerInfo)DotNetNuke.Common.Utilities.CBO.FillObject(DataProvider.Instance().GetLocationsByVendor(vendorId), typeof(KochAirVendorManagerInfo));
}
publicArrayList GetLocationsByVendor(int vendorId)
{
return DotNetNuke.Common.Utilities.CBO.FillCollection(DataProvider.Instance().GetLocationsByVendor(vendorId), typeof(KochAirVendorManagerInfo));
}
publicList<KochAirVendorManagerInfo> GetLocationsByVendor(int vendorId)
{
return DotNetNuke.Common.Utilities.CBO.FillCollection(DataProvider.Instance().GetLocationsByVendor(vendorId), typeof(KochAirVendorManagerInfo));
}

As far as the format of my data, i'm simply pulling the vendorId from the table. Its an integer.

CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 11:51 AM  

Sorry. I'll try again to not cram it all together...

 

publicKochAirVendorManagerInfo GetLocationsByVendor(int vendorId)return (KochAirVendorManagerInfo)DotNetNuke.Common.Utilities.CBO.FillObject(DataProvider.Instance().GetLocationsByVendor(vendorId), typeof(KochAirVendorManagerInfo));publicArrayList GetLocationsByVendor(int vendorId)return DotNetNuke.Common.Utilities.CBO.FillCollection(DataProvider.Instance().GetLocationsByVendor(vendorId), typeof(KochAirVendorManagerInfo));publicList<KochAirVendorManagerInfo> GetLocationsByVendor(int vendorId)return DotNetNuke.Common.Utilities.CBO.FillCollection(DataProvider.Instance().GetLocationsByVendor(vendorId), typeof(KochAirVendorManagerInfo));

{

 

}

 

{

 

}

 

{

 

}

CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 11:55 AM  
sorry. that was no help either.

If you meant how is data formatted that I am returning, I've not been able to get it to return anything. I can't get the code to compile.

And I'm sre my attempt at a List<> isn't correct either. It keeps telling me I cant turn an arraylist into a list. I thin I understand what its talking about but I cant find anything on the proper way to set up the CBO
CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 12:26 PM  
Mitchel,

So I just got kinda confirmed that this code I used before was probably correct:

KochAirVendorManagerController objLocation = new KochAirVendorManagerController();
List objLocationInfo = new List();

objVendorInfo = objVendorDetails.GetLocationsById(locationId);

THEN I would loop as so:

for(int i = 0; i < 6; i++)
{
Then check and see if the checkbox should be checked;
}

So I'm now pretty positive that I'm off somewhere in my controller class. Can you helpme get that part setup?
CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 12:28 PM  
For anyone looking;

objVendorInfo = objVendorDetails.GetLocationsById(locationId);

Should be:

objLocationInfo = objLocation .GetLocationsById(locationId);

But I think you get the point.
CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 2:04 PM  
AHA! I got it working... mainly. I'm still working through the bugs and will post the finished code for anyone who may run into the same issues when I finish. THANKS FOR EVERYTHING!!

CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 2:11 PM  

OK, first my controller;publicList<KochAirVendorManagerInfo> GetKochAirLocationsByVendor(int vendorId)return DotNetNuke.Common.Utilities.CBO.FillCollection<KochAirVendorManagerInfo>(DataProvider.Instance().GetKochAirLocationsByVendor(vendorId));

 

{

 

}

 

Then my function/method whateva you call it...publicvoid SetLocations(int locationId, CheckBox locationBox)int vendorId = Convert.ToInt32(Request.QueryString["vendor"]);KochAirVendorManagerController objLocation = newKochAirVendorManagerController();List<KochAirVendorManagerInfo> objLocationInfo = newList<KochAirVendorManagerInfo>();for (int i = 0; i < objLocationInfo.Count; i++) if (objLocationInfo.LocationId == Convert.ToInt32(locationId))true;

 

{

 

 

 

objLocationInfo = objLocation.GetKochAirLocationsByVendor(vendorId);

 

 

{

 

{

locationBox.Checked =

}

}

 

}

CoreyUser is Offline
New Poster
New Poster
Posts:16

06/02/2008 2:14 PM  

dangit. Why wont this editor allow my code to post properly. Sorry for all additions mitchel.

Anyways, I go through and check to see if my row value matches the locationId, if it does, it checks the checkbox.

If anybody finds this and needs a better look at it let me know. Im sure there are better and cleaner ways to do it, any suggestions are welcome. thanks.

You are not authorized to post a reply.
Forums >Development Discussion >DotNetNuke > looping through and arraylist in dnn



ActiveForums 3.7