Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

2/28/13

ASP.NET 2.0, Parent/Child Data Control? | DaniWeb

We're a community of 1058K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,057,146 Mem bers Technology Publication meets Social M edia

JOIN DANIWEB

MEMBER LOGIN

LOG IN WITH FACEBOOK


Search

Hardware & Software

Software Development

Web Development

Internet Marketing

Business Exchange

Community Center

Web Development > ASP.NET > ASP.NET 2.0, Parent/Child Data Control? Start New Discussion Reply to this Discussion

tgreer
Made Her Cry

7 Years Ago

Team Colleague
2,118 posts since Dec 2004

ASP.NET 2.0, Parent/Child Data Control?


Has ASP.NET 2.0 introduced a simplified data control for displaying parent/child data? Imagine a HelpDesk application, where you want to display all the "open tickets". I can see how you'd use a GridView for that. However, each row in the resulting table should have the ability to, when clicked/selected show all the "details" for that ticket. Make sense? Two separate queries, related by an identity field. I know how to do this with a DataGrid, and this is typically referred to as "Master/Detail" or "Parent/Child" data. I'm just wondering if there is anything new in ASP.NET 2.0 that simplifies this. 5
Contributors Ads by Google

6
Replies

2 Months
Discussion Span

6 Years Ago
Last Updated

8
Views

Related Article: Asp.net

2.0 is a ASP.NET discussion thread by fmardani that

has 2 replies and was last updated 7 years ago.


Ads by Google

tgreer
Made Her Cry

7 Years Ago Experiments continue... It's simple enough to create a SqlDataSource which selects all of the "master" records, and to bind that to a GridView. If one sets the "Enable Selection" to True, it adds a select command control to each row. Then, add a second SqlDataSource, tied to a query or stored procedure that displays the detail. In the wizard, one can specify that a parameter comes from a control, in this case, our first GridView. Create a second GridView, bound to the second SqlDataSource. Now, when the user clicks "Select" in the parent GridView, the child GridView displays all the associated detail records. All well and good. The issue is formatting. I don't want two separate GridViews. I want the second, child or "detail" GridView to display

Team Colleague
2,118 posts since Dec 2004

underneath the parent row. Each "detail" listing should be collapsible... it should be possible to display as many "detail" sections as the user wants. Any suggestions on how to go about that?

tgreer
Made Her Cry

7 Years Ago So many of the C#/ASP.NET threads I start end up with me just talking to myself. Hopefully, everyone is following along diligently, just waiting for a chance to jump in. THIS IS YOUR CHANCE!

Team Colleague
2,118 posts since Dec 2004

www.daniweb.com/web-development/aspnet/threads/39591/asp.net-2.0-parentchild-data-control

1/5

2/28/13

ASP.NET 2.0, Parent/Child Data Control? | DaniWeb


I've given up on GridView. I'm using Repeaters, instead. I have one "static" Repeater, coded to display the "Parent" rows. There is a LinkButton element in the Repeater. There is also a PlaceHolder. When the LinkButton is clicked, I dynamically create a second Repeater, completely in code, bind it in code, and add that Repeater to the PlaceHolder. This dynamic Repeater contains all the "Detail" rows. The issue I need some help with is, re-creating all of the dynamic Repeaters which the user has chosen to display. I fully understand the issue... the codepath only creates one dynamic Repeater on PostBack. I need some mechanism to re-create all previously rendered Repeaters. Session? Note: this renders very ugly for now. First comes logic, then comes StyleSheets Here is the declarative syntax for the page.: 1 <@Pg Lnug=C"AtEetiep"re CdFl=so_s.sxc"Ihrt=so_s"% . % ae agae"# uovnWru=tu" oeie"hwtrap.s neis"hwtr > 2 . 3 <DCYEhm PBI "/WC/T XTL10Tastoa/E" . !OTP tl ULC -/3/DD HM . rniinl/N "tp/www.r/Rxtl/T/hm1tastoa.t" ht:/w.3ogT/hm1DDxtl-rniinldd> 4 . 5 <tlxls"tp/www.r/99xtl > . hm mn=ht:/w.3og19/hm" 6 <edrnt"evr> . ha ua=sre" 7 . 8 . 9 <ha> . /ed 1. <oy 0 bd> 1. 1 1. 2 1. 3 1. 4 1. <al> 5 tbe 1. 6 1. 7 1. 8 1. 9 2. 0 2. 1 2. 2 2. 3 2. 4 2. 5 2. 6 2. 7 2. 8 2. 9 3. 0 3. 1 3. 2 3. 3 %'+/s:ikutn >><apLnBto> 3. 4 3. 5 3. 6 3. 7 3. 8 3. 9 4. 0 4. 1 4. 2 4. <tbe 3 /al> 4. 4 4. 5 4. 6 4. 7 4. 8 4. <bd> 9 /oy 5. <hm> 0 /tl And the code-behind: <dv /i> <fr> /om <t> /d <t> /r <s:lcHle I=pDti"rnt"evr>/s:lcHle> apPaeodr D"heal ua=sre"<apPaeodr <IeTmlt> /tmepae <apRpae> /s:eetr <sa> /pn <pn PolmDti:<sa> sa> rbe eal /pn <pn<sa>% DtBne.vlCnanr "aatmdsrpin)%<sa> sa>/pn<# aaidrEa(otie, DtIe.ecito" >/pn <t> /r <ted /ha> <s:eetrI=rtIse rnt"evr OIeCmad"prsu_tmomn" apRpae D"prsu" ua=sre" ntmomn=rtIseIeCmad> <tmepae IeTmlt> <r t> <d<#DtBne.vlCnanr "aatmisei" %<t> t>% aaidrEa(otie, DtIe.su_d) >/d <d<#DtBne.vlCnanr "aatmsbet)%<t> t>% aaidrEa(otie, DtIe.ujc" >/d <d<#DtBne.vlCnanr "aatmDp" %<t> t>% aaidrEa(otie, DtIe.et) >/d <d<#DtBne.vlCnanr "aatmAp)%<t> t>% aaidrEa(otie, DtIe.p" >/d <t> /r <r t> <dclpn"" t osa=4> <pn sa> <s:ikutnI=lkDti"rnt"evr apLnBto D"nbeal ua=sre" Cmadruet'% DtBne.vlCnanr "aatmisei" omnAgmn=<# aaidrEa(otie, DtIe.su_d) <ha> ted <r t> <hTR#/h<hSbet/h<hDprmn<t>t>plcto<t> t>S <t>t>ujc<t>t>eatet/h<hApiain/h <omi=fr1 rnt"evr> fr d"om" ua=sre" <i> dv <il>nildPg<tte tteUtte ae/il> <ikhe=Syehe.s"rl"tlset tp=tx/s"/ ln rf"tlSetcs e=syehe" ye"etcs >

www.daniweb.com/web-development/aspnet/threads/39591/asp.net-2.0-parentchild-data-control

2/5

2/28/13
1 uigSse; . sn ytm 2 uigSse.aa . sn ytmDt;

ASP.NET 2.0, Parent/Child Data Control? | DaniWeb

3 uigSse.aaSllet . sn ytmDt.qCin; 4 uigSse.ofgrto; . sn ytmCniuain 5 uigSse.olcin; . sn ytmCletos 6 uigSse.e; . sn ytmWb 7 uigSse.e.euiy . sn ytmWbScrt; 8 uigSse.e.I . sn ytmWbU; 9 uigSse.e.IWbotos . sn ytmWbU.eCnrl; 1. uigSse.e.IWbotosWbat; 0 sn ytmWbU.eCnrl.ePrs 1. uigSse.e.IHmCnrl; 1 sn ytmWbU.tlotos 1. 2 1. pbi prilcasso_s :Sse.e.IPg 3 ulc ata ls hwtr ytmWbU.ae 1. { 4 1. 5 1. 6 1. 7 1. 8 1. 9 2. 0 2. 1 2. 2 2. 3 2. 4 2. 5 2. 6 2. 7 2. 8 2. 9 3. 0 3. 1 3. 2 3. 3 3. 4 3. 5 3. 6 3. 7 3. 8 3. 9 4. 0 4. 1 4. 2 4. 3 4. 4 4. 5 4. 6 4. 7 4. 8 4. 9 5. 0 5. 1 5. 2
Recently Updated Articles

pbi Sloncincn; ulc qCneto on pbi Slomn cd ulc qCmad m; pbi Slaaedrd; ulc qDtRae r poetdvi Pg_odojc sne,Eetrse rtce od aeLa(bet edr vnAg ) { SsinAd"uhpr" 1; eso.d(at_es, ) cn =nw on e SloncinCniuainaae.oncintig[HLDSCnetoSrn".oncintig; qCneto(ofgrtoMngrCnetoSrns"EPEKoncintig]CnetoSrn) cn.pn) onOe(; cd=nwSlomn(sSlcIseyes,cn) m e qCmad"peetsuBPr" on; cdCmadye=CmadyeSoePoeue m.omnTp omnTp.trdrcdr; cdPrmtr.d(@es,SlbyeIt; m.aaeesAd"pr" qDTp.n) cdPrmtr[@es]Vle=Ssin"uhpr"; m.aaees"pr".au eso[at_es] d =cdEeueedr) r m.xctRae(; rtIseDtSuc =d; prsu.aaore r rtIseDtBn(; prsu.aaid) d.ls(; rCoe) } poetdvi rtIseIeCmadOjc Sne,RpaeCmadvnAg e rtce od prsu_tmomn(bet edr eetromnEetrs ) { i (.tmIeTp = LsIeTp.tm| eIe.tmye= f eIe.tmye = ittmyeIe | .tmIeTp = LsIeTp.lentnIe) ittmyeAtraigtm { cdPrmtr.la(; m.aaeesCer) cd=nwSlomn(sSlcHsoyysu" cn) m e qCmad"peetitrBIse, on; cdCmadye=CmadyeSoePoeue m.omnTp omnTp.trdrcdr; cdPrmtr.d(isei" SlbyeIt; m.aaeesAd"su_d, qDTp.n) cdPrmtr[isei".au =Sse.ovr.on3(.omnAgmn) m.aaees"su_d]Vle ytmCnetTIt2eCmadruet; RwepaemRw=nwRwepae) oTmlt yo e oTmlt(; Rpae rtDtis=nwRpae(; eetr preal e eetr) d =cdEeueedr) r m.xctRae(; rtDtisDtSuc =d; preal.aaore r rtDtisIeTmlt =mRw preal.tmepae yo; rtDtisDtBn(; preal.aaid) d.ls(; rCoe) Paeodrp =(lcHle).tmFnCnrl"heal) lcHle h PaeodreIe.idoto(pDti"; p.otosAdrtDtis; hCnrl.d(preal)

5. 3 5. 4 5. 5 5. 6 5. 7 5. 8 5. 9 6. 0 6. 1 6. 2 6. 3

Join the DaniWeb Community

} } pbi casRwepae:Iepae ulc ls oTmlt Tmlt { pbi vi IsataenCnrlcnanr ulc od ntnitI(oto otie) { Ltrloto dtiRw=nwLtrloto(; ieaCnrl ealo e ieaCnrl) dtiRwDtBnig+ nwEetade(ealo_aaidn) ealo.aaidn = e vnHnlrdtiRwDtBnig;

www.daniweb.com/web-development/aspnet/threads/39591/asp.net-2.0-parentchild-data-control

3/5

2/28/13
6. 4 6. 5 6. 6 6. 7 6. 8 6. 9 7. 0 7. 1 "/d"+ <t> 7. 2 7. 3 7. 4 <t>; /r" 7. 5 7. 6 7. } 7 } } }

ASP.NET 2.0, Parent/Child Data Control? | DaniWeb


cnanrCnrl.d(ealo) otie.otosAddtiRw;

pbi vi dtiRwDtBnigojc sne,Eetrse ulc od ealo_aaidn(bet edr vnAg ) { Ltrloto dtiRw=(ieaCnrlsne; ieaCnrl ealo Ltrloto)edr RpaeIe cnanr=(eetrtmdtiRwNmnCnanr eetrtm otie RpaeIe)ealo.aigotie; dtiRwTx ="t>t> +DtBne.vlcnanr "aatmato" + ealo.et <r<d" aaidrEa(otie, DtIe.cin) "t> +DtBne.vlcnanr "aatmtmsap)+"/d"+ <d" aaidrEa(otie, DtIe.ietm" <t> "t> +DtBne.vlcnanr "aatmnm" +"/d"+ <d" aaidrEa(otie, DtIe.ae) <t> "t> +DtBne.vlcnanr "aatmdti" +"/d <d" aaidrEa(otie, DtIe.eal) <t>

BTW, if you've ever wondered how to dynamically create a Repeater complete with an ItemTemplate and DataBinding, programmatically, the above code in orange demonstrates this very nicely! You're welcome. Now, once I get this issue resolved, the next step is to implement the detail rows as ClientCallbacks, so that as new records are added to the details table, they'll "magically appear" in the page.

tgreer
Made Her Cry

7 Years Ago

Team Colleague
2,118 posts since Dec 2004

Figured it out. I'll write this up, eventually. The answer is to create a public class with two properties, the id of the record needed for the query to the details, and the UniqueID of the Placeholder for a pariticular row/item in the parent. Store these objects in a List<> generic, marked as Serializable. Store the List object in ViewState. Then, loop through the List, building the Repeater dynamically for each item in the List.

f1 fan
Posting Whiz in Training 279 posts since Jan 2006

7 Years Ago

Not had time to look over the code yet sorry. Couldnt you put a repeater in a user control and then you would be able to expand every one? I cheat. I bought the Infragistics controls years ago as they save me so much time. They have had hierarachical grids for a few years in both win forms and asp.net. I know its good to make your own, but why reinvent the wheel when there are other things that need doing :D But if you do have the time then maybe worth thinking about writing the control from scratch based on the repeater rather than a user control?

Craig Pelkie
New bie Poster 1 post since Mar 2006

6 Years Ago Would the System.Web.UI.WebControls.DetailsView provide the detail display capabilities that you're after? In .NET 1.1 I coded an HTML table with embedded text boxes, the DetailsView provides similar functionality with the benefit of being a single control.

BoggyBoy
New bie Poster 1 post since Apr 2006

6 Years Ago

Would the System.Web.UI.WebControls.DetailsView provide the detail display capabilities that you're after? In .NET 1.1 I coded an HTML table with embedded text boxes, the DetailsView provides similar functionality with the benefit of being a single control.

Take a look at this...

http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples/data/GridViewMasterDetails.src

Ads by Google

1000
www.daniweb.com/web-development/aspnet/threads/39591/asp.net-2.0-parentchild-data-control 4/5

2/28/13

ASP.NET 2.0, Parent/Child Data Control? | DaniWeb


75% ! Booking.com/Barcelona

You

This article has been dead for over three months: Start a new discussion instead
Post: Bold Italic Cd oe Iln Cd nie oe Link Quote Heading Sub-Heading # List List
Undo

Markdown Syntax: Formatting Help


Redo

Reply to this Discussion (Alt+S)

0
Tw eet

0
Like Share

Web Development > ASP.NET

.ascx .net 2.0 ajax array asp

asp.net

bind blob

c#

calendar checkbox checkboxlist columns company connect connection control create css data database datalist dataset datetime

developement display dropdown dropdownlist exists field file firefox formview from get google gridview healthmonitor hierarchical hospital html i image images in java jquery jsp list login mail monitor mysql navigationmenu net no oracle out page paypal place plugin problem proxy radiobutton refresh response sandbox second selectedvalue server service session share sharepoint sql sqlserver2008 store table textbox to toolkit total translate update upload user value vb vb.net view vs web webcam webform webservice xml 2008 2010

2013 DaniWeb LLC Page rendered in 0.5084 seconds using 2.28MB

Home

About Us

Contact Us

Consulting

Press Kit

Advertising

RSS Feed

TOS

Donate

API

Typing

Rules

www.daniweb.com/web-development/aspnet/threads/39591/asp.net-2.0-parentchild-data-control

5/5

You might also like