Tangible Thoughts

SharePoint, MOSS? and all the other questions

  Home  |   Contact  |   Syndication    |   Login
  858 Posts | 6 Stories | 482 Comments | 2088 Trackbacks

News

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Linky Things

SharePoint Bloggers

SharePoint Related

What I am playing

What I am Reading

I found out today to my surprise that you can actually use the DataView WebPart (and all all the other SharePoint WebParts) as a control in a WebPart that you are creating.

Isn’t that sweet?

Its also remarkably easy to use.

It goes something like this

class YourWebPart : Microsoft.SharePoint.WebPartPages.WebPart

{

...

private DataViewWebPart dvwp;

...

protected override void CreateChildControls()

{

...

dvwp = new DataViewWebPart();

dvwp.DataFields = DATAFIELDS;

dvwp.DataQuery = QUERY;

dvwp.Xsl = XSL;

Controls.Add(_dvwp);

...

}

protected override void RenderWebPart(HtmlTextWriter output)

{

...

dvwp.RenderControl(output);

...

}

...

}

Where DATAFIELDS consists of the fields in the DVWP e.g. @ID,ID;@Title,Title;@Modified,Modified etc, which you can extract from a DVWP inserted from FrontPage

Likewise QUERY is the data query which also can be extracted off a DVWP inserted in FrontPage; it is denoted by the <udc:ConnectionInfo> info tag. And XSL is the XSL that would transform the fetched data.

posted on Tuesday, August 31, 2004 11:15 AM

Feedback

# re: Using a DVWP in a WebPart 9/25/2004 5:53 AM tedteng
Thanks for ur wise info. I thought the webpart cannot be displayed in a nesting way.

# re: Using a DVWP in a WebPart 12/16/2004 4:07 PM andreas
Could you, please, post a sample of such a web part(one that contains a DVWP). I have spent many hours, trying to set the above mentioned properties without any succes.

Thanks

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: