.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Data View Web part, stored procedures, and sorting

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :SharePoint

I know I'll probably never get an answer to this because it seems that no one uses the Data View Web Part and there is a dearth of documentation (sigh), but here goes...


In MOSS2007, I need to call a stored procedure and get the data back and display it in the Data View Web Part.  I can do that.


The problem is enabling sorting.  I can enable sorting in the DVWP and it allows me to click the column headings and supposedly sort the data - but it doesn't sort it.  It does a postback, but doesn't affect the output.


I did some tracing with SQL Profiler, and found that if I use a SELECT statement, the sorting causes the web part to add the "ORDER BY" clause using the appropriate field.


However, since this is a stored proc, it does not seem to do anything - it just keeps calling the same stored proc over and over.


What I suppose I need it to do is pass the stored proc a parameter to tell it what order to sort the data - but I don't see any way to do that.  I can pass the stored proc parameters via the DVWP, but how do I figure out what sort field was selected and pass that?  Anyone know?


View Complete Post

More Related Resource Links

.NET Reflection: Dynamically Bind Your Data Layer to Stored Procedures and SQL Commands Using .NET M


One major inconvenience of using SQL stored procedures from code is having to match type information. You have to write long wrapper functions around the procedures just to expose the data types. In the .NET Framework, however, the reflection services of the System.Reflection namespace allow you to query rich metadata that describe data types. This article explains how to use reflection in .NET to end your stored procedure nightmares. The author creates four custom classes, including one that generates a SQLCommand object based on the metadata of a method. Using this library, you'll be on your way to automating the generation of stored procedures.

Atif Aziz

MSDN Magazine August 2002

Add page numbers for paging in data view web part


Hello all,

Has anyone found a solution that will allow me to have page numbers for paging in a data view web part. For instance, if I have 40 items/rows and I set the paging to display 10 items, I'd like the paging to show 1 2 3 4 rather than showing 1-10 and having to click next over and over to get to a specific item.

I found this article, but it is for 2003 and doesn't seem to apply to 2007 or if it does I am not able to really figure out how.


Please help!

Thanks in advance.


Group by library name using Data View Web Part

I'm using a data view web part to disply documents in multiple libraries.  Is it possible to group on the name of the library instead of grouping on an individual column? Thanks

In data view web part - how to display document name with link that opens lookup document rather tha

I have a list with a lookup column to create relationships with documents in a separate library. I am creating a data view web part to display each item in the list. One of the fields I want to display is the document field (the lookup column). I want this to be in the form of the related document's name with link to directly open the source document itself (Word, PPT, ...). Now I am only managing to display the document name linked to opening the document's display form of the related document library, and then I have to click the document's name there to open it. Alas one unnecessary click too many. Any wize tips? Henning

Displaying a count of records in a Data View Web Part outside the web part itself?

I have a DVWP with 400 rows. I have these inside a Div tag, which makes it scrollable. I also have several URL filters set up to show certain records. I would like to add the count to the page to display the number of records when the filters are activated. I have added the View Footer to the DVWP but this just gets placed at the bottom (still inside the Div tag). It would also be cool to be able to do counts with criteria so I could do comparisons (ie, 50 records overdue/400 total etc). Thanks

format-number issues with the Data View Web Part in SharePoint 2010

I have a number column named @Year_x0020_1_x0020_Revenue in the data view web part in SharePoint Designer 2010. In the Xpath expression builder - @Year_x0020_1_x0020_Revenue previews "500,000" If I use the format-number in the Xpath expression builder ==> format-number(@Year_x0020_1_x0020_Revenue, '$#,##0.00;-$#,##0.00'), it returns NaN. Is there any reason? 

Data View Web Part in SharePoint Designer 2010

Is Data View Web Part (aka Data Form Web Part) in the SharePoint 2010 has changed from the SharePoint 2007 or Is it working differently in the SharePoint Designer 2010? In SharePoint Designer 2007, whenever you have data view web part on the page, there is little handle to click on the top right of the data view web part to show Common Common Data View Tasks. Also for each cell, there was a handle to show xsl:value-of tasks which was great for formatting. Is that option is gone in the SharePoint Designer 2010?

data view web part - read and write using web service

Hi I am looking for an example on "Data View Web Part" in WSS 2010 to read and write data from a web service that I have written and then update the database. or if you have a any better way of doing this function of reading and writing data to and from "Data View Web Part" in WSS 2010. Thanks heapes in advance. Kind Regards,  sword

how to write xslt in data view web part to display visifire charts

Hello All, I am writing xslt to display created by column in visifire charts. but it is not displaying chart. same code for displaying custom column is working fine but i dont know where i am going wrong in case of created by column. i put internal name also which is author for this column but no luck. below is the code i had used to display visifire chart. <xsl:text disable-output-escaping="yes">     <![CDATA[                     + ' <vc:DataPoint AxisXLabel="DTL3]]></xsl:text>   <xsl:text disable-output-escaping="yes"><![CDATA[" YValue="]]></xsl:text>     <xsl:value-of select="count(/dsQueryResponse/Rows/Row[normalize-space(@Author) = 'A'])"/>     <xsl:text disable-output-escaping="yes"><![CDATA[" LabelText="DTL3]]></xsl:text>     <xsl:text disable-output-escaping="yes"><![CDATA[" Exploded="False]]></xsl:text>     <xsl:text disable-output-escaping="yes"><![CDATA["/>']]></xsl:text> but the same code for different column name is working fine. please provide your inputs, where i am doing wr

Data view web part: Change Data Source

I have a data view web part that I would like to use multiple time in the same page, but tied to different sharepoint lists.  Is there an efficient way to do this?

I can add additional data sources, but I don't see how I can remove the original.

How to get Email of Current User Data View Web Part Sharepoint 2010 and pass to WebService data sour

I have to pass in the email address of the current user to a web service data source (run time) of a Data View Web Part.

My Question is:

a) How can I get Email address of current user based  in DVWP.
I know we can get the CurrentUser using the CurrentUserName but how do we get the Email for the Current User.

b) After getting the Email how do we pass to the Web Service.

Pass information from one web service to another web service in the same data-view-web-part


In Data View Web Part.

Is it possible to pass information from one web Service data source connection to another web service data source connection within the same Data Form Web Part to get information from second web service?

What I am trying to achieve is to get user email address from the User Profile Web Service and pass in to another web service to get information.

Please advise if it is possible.

Stored Procedures using XQuery to insert XML data into tables


If I have the following XML being passed as a parameter into a stored procedure.


<name>My Bookstore</name><br/>
<location>New York</location><br/>
 <title lang="eng"&g

How to Pass data(not the part of model) from View to Controller?


How Can I Pass data(not the part of model) to Controller from View?
View Code

<%= Html.ActionLink(item.Name, "ActionName", "ControllerName", new { companyID = Html.Encode("abc"), ID = Html.Encode("xyz") })%>

Controller Code

public ActionResult ActionName(string companyID , string ID)

Any idea?

Data view web part and item menu


Good morning, I'm using the SharePoint Designer 2007 and I would like to show the item menu using the data view web part. Below is an example of what I want to do:

How can I do that?

Data View Web Part, update to Data Source / adding new list to existing data source


Hi all,

I have four Lists with identical columns :

List 1
List 2
List 3
List 4

I had to merge them, hence i created a data source ( Linked Source ) and merged these lists in SPD. I have used a data view webpart to display some columns from the merged lists data source and everything was working fine.

But now i have a new List : List 5 which also has the same columns like the other four lists and i need to update the data soure such that it is merged list of 5 lists not 4.

i updated the datasource property of the linked source to merge this new list as well. However the contents of List 5 dont appear in the data view webpart. 

Am i missing something here ? 

I dont want recreate the data view web part from scratch eachtime , because in future there might be List 6 , List 7 as well ... 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend