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.