Dataview Web Part parameter and filter Query

Source: Internet
Author: User
Tags xslt
ArticleDirectory
    • Parameter Source Type
    • Parameters and filtering
Parameter Source Type

None in SharePointCodeDataview should be an important control for customized development. It can be used to display data from data sources such as SharePoint and databases. In its control, A very important thing is "parameter". It is especially important to use it to implement parameterized query. Its Parameter source type is as follows:

    • None: this parameter does not specify any parameter source. Its source must be connected to it by other webparts, and then provide parameters for it, such as using form webpart or webpart of various filters.
    • Control: the control here refers to the server-side control. When a callback occurs on the page where dataview is located, the control value is assigned to this parameter.
    • COOKIE: obtain the value from the cookie when a callback occurs.
    • Form: it refers to a client control, that is, a control such as input. If a static control or a server control containing a static control (such as form webpart) is used, you can define parameters as data sources of this type.
    • Query string: Question mark (?) in the URL (?) Partial Parameters
    • Server variable: this refers to the server request. variable value in servervariables. sharePoint also makes some extensions to these server-side variables. For example, the logon_user variable is used to record the current Login User's
Parameters and filtering

Dataview supports two filtering methods:

    1. Query the list through caml: This query transmits the filter conditions to the database to obtain data, and limits the data obtained from the server through certain conditions.
    2. Query XML using XSLT: This query filters the data presented to the foreground by specifying XPath in XSLT from the data obtained from the server, the difference between this method and caml filtering is that this method is a "false" filter. If a large query has a significant impact on efficiency.

You can specify parameters in the preceding two types of queries to achieve dynamic filtering.

When the parameter source is "NONE", the webpart connection is used to provide parameter filtering.

Create a page, drag and drop a dataview control to add a text filter control, and create a paramtitle parameter in dataview. Select "NONE" as the parameter source ". establish a connection between dataview and text filter, as shown in:

Click Next and select "other Web Components connected to this page". The following message is displayed:

After "Next" is selected, select the two values to be connected, as shown in:

Click "Next" and select "finish ".

This establishes an association between two webparts, that is, when a page callback occurs, the value of the text filter control can assign values to the dataview parameter, then, you can use parameters to implement functions such as filtering. to set filter conditions, you can use dataview's "filter", as shown in:

You can use "add XSLT filter" here, but as I mentioned above, this method is implemented by filtering all the data through XPath, large data volumes are efficient. the filter added to this table is implemented by defining the caml Statement, which is more efficient.

After completing the operations shown above, you can implement filtering, as shown in:

The other methods are similar to this one. If you use parameters with the corresponding parameter source, you do not need to set the association between webparts (for example, the parameter source is "control, if the page contains a textbox on the server side, you only need to specify the ID of the control on the server side when defining parameters. In this way, dataview automatically obtains the value in the textbox when page callback occurs, then you can use the parameters ).

However, these methods cannot meet the requirement that "when multiple conditions are met, this condition is not used when the condition is null, in this case, you may need to define the embedded server code on the page (which reduces security) or custom webpart (you can try to make it universal) to implement dynamic caml statements for the selectcommand attribute of the dataview control.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.