Sharepoint Data Source — when developing a Visual Web Part in VS 2010

The following (“Sharepoint:SPDataSource”) is the Sharepoint Data Source – Can’t drag and
drop from Toolbox, so has to cut & Paste the source and modify

<SharePoint:SPDataSource runat=”server” ID=”countriesList” DataSourceMode=”List”
SelectCommand=”<Query><OrderBy><FieldRef Name=’Title’ Ascending=’true’/></OrderBy></Query>”> Title
is the name of the field to order by

<asp:Parameter Name=”ListName” DefaultValue=”Countries” />
“Countries” is the name of
the Sharepoint List


We have a Gridview here at the bottom

<asp:GridView ID=”GridView1″ runat=”server” DataSourceID=”countriesList” EnableModelValidation=”True”
AutoGenerateColumns=”False” AllowPaging=”True”>
<asp:BoundField DataField=”Title” HeaderText=”Country Name” />
Display this field and
<asp:BoundField DataField=”Population” HeaderText=”Country Population” />
also this field



Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: