471,591 Members | 1,855 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,591 software developers and data experts.

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 2559
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 XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

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.