in

SharePoint University

Clean slate. Nothing but SharePoint.
Go, SharePoint!

DATAFORMWEBPART using C#

Last post 01-05-2009 5:22 AM by sistema10. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 10-09-2007 4:06 AM

    • abhi
    • Not Ranked
    • Joined on 10-09-2007

    DATAFORMWEBPART using C#

    MY requirement is that I have to create custom webpart in that I need to give site url and it will populate the list available in that site(DropDownList) and when I select particular list it will populate views related to that list(DropDownList).My requirement is that I need to display DataView using .NET code

    public void btnPreview_Click(object sender, EventArgs e)

    {

     

     

    wsswp.DataFormWebPart myDataView = new Microsoft.SharePoint.WebPartPages.DataFormWebPart();

     

    SPDataSource spds = new SPDataSource();SPSite sitecol2 = new SPSite(txt.Text);

    s1 = sitecol2.OpenWeb();

    SPList selectedList = s1.Lists[ddList.SelectedItem.Text];

    spds.List = selectedList;

     

    myDataView.DataSource = spds;

    myDataView.DataBind();

    }

     

    When I am clicking preview button which is available in my webpart I am getting error

    "An error occurred processing the data view. The XslText property is empty."
    Can anybody help regarding this

  • 10-18-2007 12:40 PM In reply to

    Re: DATAFORMWEBPART using C#

    This means that you must set up Xsl or XslLink property. For example:

    DataFormWebPart.XslLink = "http://win2003/Style Library/XSL Style Sheets/ContentQueryMain.xsl";

    This will set standard SharePoint xsl templates.

    You can pass xsl template as test directly  to Xsl property.

     

     

  • 11-05-2007 4:49 AM In reply to

    • abhi
    • Not Ranked
    • Joined on 10-09-2007

    Re: DATAFORMWEBPART using C#

    I am not able to understand your point Can you be more specific and if possible can you show it by example.My first and main doubt is that in xslLink what should I write

  • 09-13-2008 7:08 AM In reply to

    Re: DATAFORMWEBPART using C#

    When you create a Data Form Web Part, you need to give it the XSLLink or the XSL property, this property allow the DataForm webpart to display the data source in an Html format. now the object of DataForm web part must initiate the XSL property or XSLLINK property such as following:

    DataFormWebPart dfwp = new DataViewWebPart(); 

    dfwp.XSLLink = "path for an XSLT file" OR

    dfwp.XSL = "<xsl:na.........></xsl>" //you can have a well formed xslt code from opening any dataview web part using Designer 2007

  • 01-05-2009 5:16 AM In reply to

    Re: DATAFORMWEBPART using C#

    I've got the same problem. The error appears when you click any button created as a server control, when it postback and before any event of the control is fired.

    It occurs only when you fill the XSL property directly in code, not when you fill it in the html page or you use the xsllink, even using exactly the same XSLT. I tried to assign the property in other methods/events along all the life cicle of the DFWP with the same problem.

    Any idea?

    In other way.... anybody knows how to find the code that is generating the error? I tried to use the Reflector to see inside the out-of-the-box DFWP, but I can't find the code that is generating the error.

  • 01-05-2009 5:22 AM In reply to

    Re: DATAFORMWEBPART using C#

    Hey! I had an idea just writting the last repply... I found that if you assign the XSL property with your XSLT in your code but you also put something between the <XSL> and </XSL> tags in the form (something, it doesn't matter, you'll fill it later with the correct XSLT), the error doesn't occurs! Now in my test project I've got another error on the onbubble event of the button, but, this is another war!

Page 1 of 1 (6 items)

Need SharePoint Training? Attend a SharePoint Bootcamp!
Forum content (c) original posters. Everything else (c) 2008 SharePoint Experts, Inc.