468,272 Members | 2,171 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

Nested DataList Question!

AJ
Hi all,

With the following code in mind :

<asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%#
GetDataSource1()" Runat="server">
<ItemTemplate>
Output Value Here!
<asp:DataList ID="dlTwo" DataKeyField="myField2" DataSource="<%#
GetDataSource2(?,?)" Runat="server">
<ItemTemplate>Output Value Here!</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>

I need to send the Data Source of the nested DataList (DataSource="<%#
GetDataSource2(?,?)) two variables.

1) myField2 value of current DataList
2) myField1 value of parent DataList

Using Databinding?

Can anyone give a head on on acheiving this???

Cheers,
Adam

Jul 20 '06 #1
1 2446
You can use the ItemDataBound event and the FindControl function to
find the second DataList, example:

Protected Sub dlOne_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
dlOne.ItemDataBound

CType(e.Row.FindControl("dlTwo"), DataList).DataSource =
GetDataSource2(?,?)
CType(e.Row.FindControl("dlTwo"), DataList).DataBind

End Sub

So, in the first DataList you can put a hidden label in the header with
the id of the parent DataList and in each row put the value of the
current DataList. Just check if the item is a Item, Alternate item,
header item, etc. like this:

If (e.Item.ItemType = ListItemType.Item) Then
End If

Hope this will help.

AJ wrote:
Hi all,

With the following code in mind :

<asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%#
GetDataSource1()" Runat="server">
<ItemTemplate>
Output Value Here!
<asp:DataList ID="dlTwo" DataKeyField="myField2" DataSource="<%#
GetDataSource2(?,?)" Runat="server">
<ItemTemplate>Output Value Here!</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>

I need to send the Data Source of the nested DataList (DataSource="<%#
GetDataSource2(?,?)) two variables.

1) myField2 value of current DataList
2) myField1 value of parent DataList

Using Databinding?

Can anyone give a head on on acheiving this???

Cheers,
Adam
Jul 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by V. Jenks | last post: by
reply views Thread by Marty U. | last post: by
3 posts views Thread by Derek | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.