tags:

views:

70

answers:

1

this is a console application code in c sharp for executing CAML queries on sharepoint server 2007

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace SharePointUtils
{
    class Program
    {
        static void Main(string[] args)
        {
            string siteUrl = args[0];
            string listName = args[1];
            string viewName = args[2];
            SPSite site = new SPSite(siteUrl);
            SPWeb web = site.OpenWeb();
            SPList employeesList = web.Lists[listName];
            SPQuery query = new SPQuery(employeesList.Views[viewName]);
            System.Diagnostics.Debug.WriteLine(query.ViewXml);
            Console.WriteLine(query.ViewXml);
            Console.ReadLine();
        }
    }
}

How would this code change if the same code is not executed as a console application but a the code is executed using a button click in actions / some similar user interaction within sharepoint list view. and the results are also displayed within sharepoint e.g in an aspx page.

And if possible please give some tips on the aspx page creation as well.

Really, a help at any level will be sincerely appreciated.

+1  A: 

A first step might be to retrieve the results as a Datatable and bind that to an aspx DataGrid/DataView control.

To get the results as a DataTable you can use the GetDataTable method of SPListItemCollection.

Moron
thanks a lot dear
silverkid