Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid in nested repeater

Status
Not open for further replies.

Lbob

Programmer
May 23, 2003
157
GB
Hi

I'm trying to achieve the following effect.

Activity 1
User 1
Week 1 Data
Week 2 Data
User 2
Week 1 Data
Week 2 Data
Activity 2
User 1
Week 1 Data
Week 3 Data
User 3
Week 1 Data
Week 2 Data

I've so far managed to get the Activity & User bit working by using 2 repeaters. I now need to add a datagrid to display the week data, it needs to be a grid because the user needs to have edit functionality on the week data. I've tried setting the datagrid to bind when the User repeater is bound but it's not working, this is what I've got. Any help would be greatly appreciated.
Lbob


<asp:Repeater id="RptActivity" runat="server">

<ItemTemplate>

<%# DataBinder.Eval(Container, "DataItem.ProjectActivityID")%>

<BR>

<asp:repeater id="RptUser" runat="server" Datasource='<%# Container.DataItem.Row.GetChildRows("RelPAUsers")%>'>

<itemtemplate>

<asp:Label ID="LblUserID" Runat="server"><%# Container.DataItem("UserID")%></asp:Label>

<asp:Label ID="LblProjectActivityID" Runat="server"><%# Container.DataItem("ProjectActivityID")%></asp:Label>

<BR>

<asp:DataGrid ID="GrdHours" runat="server" DataKeyField="ProjectActivityID" AutoGenerateColumns="False">

<Columns>

<asp:TemplateColumn>

<ItemStyle HorizontalAlign="Center" Width="20px" CssClass="grid-item"></ItemStyle>

<ItemTemplate>

<%# DataBinder.Eval(Container, "DataItem.WeekData") %>

</ItemTemplate>

</asp:TemplateColumn>

</Columns>

</asp:DataGrid>

</itemtemplate>

</asp:repeater>

</ItemTemplate>

</asp:Repeater>



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ds.Tables.Add(ListProjectActivitiesDS(50))

ds.Tables.Add(ListProjectActiviyUsersDS(50, 15))

ds.Relations.Add("RelPAUsers", ds.Tables(0).Columns("ProjectActivityID"), ds.Tables(1).Columns("ProjectActivityID"))

RptActivity.DataSource = ds.Tables(0)

Page.DataBind()

End Sub

Private Sub RptUser_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RptUser.ItemDataBound

Dim iUser As Int32 = CType(e.Item.FindControl("LblUserID"), Label).Text

Dim iProjectActivity As Int32 = CType(e.Item.FindControl("LblProjectActivityID"), Label).Text

Dim dg As DataGrid = e.Item.FindControl("GrdHours")

dg.DataSource = ListUserHours(iUser, iProjectActivity, 15)

dg.DataBind()

End Sub

 
Nested datagrids can be slightly more tricky than nested repeaters but it's still fairly straightforward depending on how complec you need to make them. For some simple examples look at any of these articles:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top