Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Accessing Datalist from outside the listAccessing Datalist from outside the list
Previous
 
Next
New Post
3/18/2008 1:59 AM
 

Hi all,

Let me say firstly, that i am very new to ASP (soon to become very obvious). I started out this current thing by following a tutorial to craft a simple trading post, by Michael Washington. And have since modified it to suit my purposes.

Basically, i have a datalist, and within each itemtemplate is also a "add link" button that displays (sets .visible = true) a form below the full data list. within each itemtemplate is also a Label containing the ID of the current record being displayed. How is it possible to transmit this ID to the form outside the datalist, it appears i have no "selected index" etc to work with when its a datalist.

This is probably wrong, but i took note in the sample, that a Class was built to hold the data for use, and connected to with an object datasource. Basically i have had to add a separate table, as entries in the main table, can have multiple related entries in the other table. I was not sure whether it was possible or advisible to modify the class to contain a ... sub class? and populate that in some fashion (or how to do so), so i simply created a separate class, and i populate it with the data for each entry in the main class... this is wher ethe problem is... the link between the Data in the main table is a foreign key ID in the second table, To populate my second class, and of course to run the insert to add to the 2nd table, i need to access the Correct ID from the original Class, to pass as the value for the foreign key (Where ID = @ID) etc...

Datalist doens't seem overly friendly in terms of indexing a selected data entry...

I apologise in advance if none of this makes sense, i haven't got much background with object oriented programing obviously, and am tackling it 'from the deep end' so to speak:). Any advice on how to achieve this is great, i figure i could use a postback to the same page, however i'd rather redesign the class structure than do that, it would seem the wrong way to go about it.

Any help greatly appreciated:)

 

 
New Post
3/18/2008 9:35 AM
 

There are several ways to pass the item id - making use of the DataKeyField / DataKeys properties of the DataList or the CommandArgument property of the link button are the most common. Here are a couple of references/tutorials that will help:

DataKeys:

http://msdn2.microsoft.com/en-us/library/90xwe9s3(VS.85).aspx
http://www.asp.net/learn/data-access/tutorial-36-vb.aspx

CommandArgument:

http://www.asp.net/learn/data-access/tutorial-46-vb.aspx


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
3/19/2008 2:43 AM
 

William,

Many thanks for the assistance, using a CommandArgument assigned to the button within each 'item' in the datalist, i was able to pass the appropriate ID and apply it to a hidden field on the form that becomes visible. I tried to get creative, and move my form from below the datalist, to within the itemtemplate - this didn't work as i expected, however i've no idea how one would make it work - naturally i get a bunch of "theform" does not exist in the current context, i've no idea how it would be targetted as a result...it was only a thought to save scrolling down below the datalist to find your form.

My next drama, is a Page_load drama i think, of course i need to retreive my Datalist, as each datalist item is populated, i also need to retrieve from the second datasource the records with an ID = to the CommandArgument, any suggestions on this - i really have no idea and i think my poor class design may make this impossible?

Ultimately, the ID field for each item in the datalist needs to be used to extract data from another objectdatasource to populate a gridview within the datalist Itemtemplate... i will keep trying to come up with a way to do this - but do you, or anyone have a suggestion as to how to go about this?

Thanks again, charles

 
New Post
3/19/2008 8:52 PM
 

Here's another of Scott Mitchels tutorials that you may find helpful:

http://www.asp.net/learn/data-access/tutorial-32-vb.aspx

You might also try a Google search on "Asp.Net nested databound controls"


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Accessing Datalist from outside the listAccessing Datalist from outside the list


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out