16.3. Using ASP.NET Controls with SharePoint Data Sources

Because SharePoint (WSS v3 and MOSS) is based on ASP.NET 2.0, you can also use the generic ASP.NET 2.0 data display controls with SharePoint data sources. When you open a SharePoint Web site in SharePoint Designer, the Data Source Library task pane shows all the available lists, libraries, and other data sources associated with the Web site. If you right-click on a data source in the Data Source Library task pane, an option to insert a data source control for the data source appears. You can bind this data source control with a generic ASP.NET data control to display data on a Web page.

In the following exercise, I show you how you can use the ASP.NET GridView control to display data from a SharePoint list. Follow these steps:

  1. Using the SharePoint interface, create a new Announcements list on your Web site and then add several items to this list.

  2. Open the SharePoint site in SharePoint Designer and then enable the Data Source Library task pane.

  3. Use the New dialog box to create a new ASPX page and then place the cursor in the Design view.

  4. In the Data Source Library, expand SharePoint Lists, right-click on the newly created Announcements list, and then choose Insert Data Source Control from the popup menu. An SPDataSource control is inserted on the Web page.

  5. Using the Toolbar task pane, insert a GridView control on the Web page.

  6. Using the Common GridView Tasks menu, select the SPDataSource control from the Choose Data Source dropdown menu.

  7. Save the Web page and then preview it in a browser.

This approach provides an alternative means to display data from SharePoint data sources on Web pages. Because inserting and updating data is obfuscated in SharePoint sites, you can't use this approach to manipulate SharePoint list data. SharePoint Designer provides you with a robust data display control called DataFormWebPart to perform these operations on SharePoint data sources.

NOTE

For more on the DataFormWebPart, see Chapter 17.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.31.165