473,756 Members | 3,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bind nested datalist to objectdatasourc e

I have a datalist (DataList1)...
with an itemtemplate...
then a table - server side (Table1)...
then another datalist (DataList2)...
another itemtemplate...
another table - server side (Table2)

DataList1 is bound to an objectdatasourc e (ObjectDataSour ce1), and has a
datakey (CategoryId). I want to bind DataList2 to another objectdatasourc e
(ObjectDataSour ce2), pulling records based on DataList1's datakey
(CategoryId).

I've set everything up, but when i run the page only DataList1 appears to
databind. Table1 renders out, but DataList2 never seems to databind.

I'm trying to do everything declaritively, is that possible? If so, what am
I doing worng?

Thanks
Jan 27 '06 #1
2 3414
Make sure that the datasource for DataList2 is within the same template that
the DataList2 is placed, because for each datalist2 instance there will be an
instance of the datasource created. I have a demo that achieved the same
declaratively albeit using a parent GridView that expands a child GridView
that in turn expands a DetailsView.
http://www.webswapp.com/CodeSamples/...idView_1c.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Phil" wrote:
I have a datalist (DataList1)...
with an itemtemplate...
then a table - server side (Table1)...
then another datalist (DataList2)...
another itemtemplate...
another table - server side (Table2)

DataList1 is bound to an objectdatasourc e (ObjectDataSour ce1), and has a
datakey (CategoryId). I want to bind DataList2 to another objectdatasourc e
(ObjectDataSour ce2), pulling records based on DataList1's datakey
(CategoryId).

I've set everything up, but when i run the page only DataList1 appears to
databind. Table1 renders out, but DataList2 never seems to databind.

I'm trying to do everything declaritively, is that possible? If so, what am
I doing worng?

Thanks

Jan 27 '06 #2
Thanks for the reply. I didn't realize that the position of the
objectdatasourc e control mattered, but apparently it does. The only
difference here is that I wanted to do the databinding without a selection
occuring (meaning there is no SelectedIndex for me to reference). I solved
this problem by putting a Label control in the first datalist and binding the
text property to the categoryId (but made the label control hidden). Then I
used the controlparamete r of the second object datasource and referenced the
text property of the label.

I read that part of the solution last night somewhere, don't remember where
as I wasn't able to get it working then (likely due to the position of the
datasource control).

All-in-all, everything seems to be working now. Thanks again for the reply,
and nice samples on your site there.

Thanks.

"Phillip Williams" wrote:
Make sure that the datasource for DataList2 is within the same template that
the DataList2 is placed, because for each datalist2 instance there will be an
instance of the datasource created. I have a demo that achieved the same
declaratively albeit using a parent GridView that expands a child GridView
that in turn expands a DetailsView.
http://www.webswapp.com/CodeSamples/...idView_1c.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Phil" wrote:
I have a datalist (DataList1)...
with an itemtemplate...
then a table - server side (Table1)...
then another datalist (DataList2)...
another itemtemplate...
another table - server side (Table2)

DataList1 is bound to an objectdatasourc e (ObjectDataSour ce1), and has a
datakey (CategoryId). I want to bind DataList2 to another objectdatasourc e
(ObjectDataSour ce2), pulling records based on DataList1's datakey
(CategoryId).

I've set everything up, but when i run the page only DataList1 appears to
databind. Table1 renders out, but DataList2 never seems to databind.

I'm trying to do everything declaritively, is that possible? If so, what am
I doing worng?

Thanks

Jan 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2000
by: Derek | last post by:
I have a nested datalist with a dropdownlist. I need to capture the selectedvalue of the dropdownlist so I can update a database table. My question then is...how do I get the value from the nested datalist? Thanks for any help.
0
1850
by: H5N1 | last post by:
Hi there My problem is that in when I update GridView row, which is nested into DataList control, I want to refresh also DataList in which the GridView is nested, since after update, trigger in my DB changes some value in it (some Total sum from the GridView column). The GridView, along with its ObjectDataSource is inserted into DataList ItemTemplate.
1
3415
by: H5N1 | last post by:
Hello everybody I'm stuck for a long time with the following problem, so I will be really gratefull if you could help me a bit: I have a GridView nested in DataList (it's located in DataList's Item Template together with it's data source). In OnRowUpdated event of child GridView I'm calling DataBind() on parent DataList, since I want it to reflect the changes (maybe there's
1
3161
by: Jules | last post by:
We have a problem setting, actually resetting, the SelectedItemTemplate of a DataList control. Below is the ObjectDataSource and the DataList in .ASPX: <asp:ObjectDataSource ID="mySource" runat="server" SelectMethod="GetStageUsage" TypeName="SomeController"> </asp:ObjectDataSource> <asp:DataList ID="dl" runat="server" DataSourceID="mySource" DataKeyField="ID" OnItemCommand="dl_ItemCommand">
0
3116
by: TheDude5B | last post by:
HI, I am creating a DataList by using the SelectMethod from an ObjectDataSource. Within each item I want to be able to the dynamically create a drop down list depending on what the ProductID is which is being pulled from the ObjectDataSource. How can I do this? Protected Sub DataList2_DataBinding(ByVal sender As Object, ByVal e As
0
2183
by: GMartin | last post by:
I have a pop-up form with a three columned Grid that has checkboxes in a Template Column in the first/left-most column. (The form is to allow users to select "Members" of a group, where they check or clear the boxes next to the potential members they want to add or remove.) The Object Data Source is as follows... <asp:ObjectDataSource ID="odsMembers" runat="server" SelectMethod="GetGroupMembersSelectList"...
0
1672
by: Mark Micallef | last post by:
Hi, I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm using: <InsertItemTemplate> <div class="insertArea"> <asp:DropDownList ID="lstUser" runat="server" DataSourceID="UserDataSource" DataTextField="UserName" DataValueField="UserId" SelectedValue='<%# Bind("UserId") %>' AppendDataBoundItems="true"></asp:DropDownList> <asp:TextBox ID="txtPhone" runat="server"...
1
2622
by: Mark Micallef | last post by:
Hi, this question relates to a control in the Ajax toolkit for asp.net 2. I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm using: <InsertItemTemplate> <div class="insertArea"> <asp:DropDownList ID="lstUser" runat="server" DataSourceID="UserDataSource" DataTextField="UserName" DataValueField="UserId" SelectedValue='<%# Bind("UserId") %>'...
0
1328
by: nzkks | last post by:
Hi, I am using these: ASP.Net 2.0, VB.Net, Visual Studio 2005, SQL Server 2005, Objectdatasource using DAL & BLL classes My objectdatasource can produce below output by CategoryID parameter: (stored procedure: GetProductsByCategoryID ) CategoryID | CollectionID | ProductID | CategoryName | CollectionName | ProductName | ProductPhoto 1 1 3 XYZ ABC Prod3 ...
0
9325
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9152
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9716
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9716
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8569
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6410
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4996
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3676
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.