From: Guabble on 5 Feb 2007 11:26 Adrian Sorry to bug you but what is a DataView object? cheers mike On Feb 5, 1:25 pm, Adrian Jones <AdrianJo...(a)discussions.microsoft.com> wrote: > Hi Mike, > > I'm a relative newbie to ASP.NET, so please excuse me if anything here is > done a bit back to front. But I've just used something like this to solve > something similiar to what you describe: > > <!-- ========================================== > Gridview with repeater > ========================================== --> > > <asp:GridView ID="gvParent" runat="server" > AutoGenerateColumns="False" > DataSourceID="sqlParent" > DataKeyNames="ParentID" > OnRowDataBound="gvParent_RowDataBound" > > <Columns> > <asp:TemplateField HeaderText="Description"> > <ItemTemplate> > <asp:Label ID="lblDescription" runat="server" > Text='<%# Eval("Description") %>' /> > </ItemTemplate> > </asp:TemplateField> > <asp:TemplateField HeaderText="Child Data "> > <ItemTemplate> > <asp:Repeater ID="rptChild" runat="server"> > <ItemTemplate> > <asp:Label ID="lblChildDataField" > runat="server" > Text='<%# Eval("ChildDataField") %>'/> > </ItemTemplate> > </asp:Repeater> > </ItemTemplate> > </asp:TemplateField> > </Columns> > </asp:GridView> > > <!-- ================================================= > SQL sources for Parent and Child > ================================================ --> > > <asp:SqlDataSource ID="sqlChild" runat="server" ConnectionString="<%$ > ConnectionStrings:connString %>" > SelectCommand="GetChildData" SelectCommandType="StoredProcedure"> > <SelectParameters> > <asp:ControlParameter ControlID="gvParent" Name="ParentID" Type="Int32" /> > </SelectParameters> > </asp:SqlDataSource> > <asp:SqlDataSource ID="sqlParent" runat="server" > ConnectionString="<%$ ConnectionStrings:connString %>" > SelectCommand="GetParentData" SelectCommandType="StoredProcedure"> > </asp:SqlDataSource> > > <-- In code-behind to databind each set of child data when parent is databound > ================================================= --> > > protected void gvParent_RowDataBound(object sender, GridViewRowEventArgs e) > { > if (e.Row.RowType == DataControlRowType.DataRow) > { > Repeater rep = (Repeater)e.Row.FindControl("rptChild"); > string ID = > gvParent.DataKeys[e.Row.DataItemIndex].Value.ToString(); > sqlChild.SelectParameters[0].DefaultValue = ID; > DataView dv = (DataView)sqlChild.Select > (DataSourceSelectArguments.Empty); > rep.DataSource = dv; > rep.DataBind(); > } > > > > }- Hide quoted text - > > - Show quoted text - d\
From: Guabble on 5 Feb 2007 11:59
you da ma! Loving it. got it working, thanks very much. Didn;t know about dataviews. There seems there is so much in .net that you just dont know about! thanks v much |