SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm binding my SPDataSource to an ASP:DataGrid but it returns empty gridview not filled. Here's my aspx file

<SharePoint:SPDataSource runat="server" ID="SPTypes" DataSourceMode="ListItem" UseInternalName="true"> 
<asp:gridView ID="GV" runat="server" DataKeyNames="Title"  AutoGenerateColumns="False" AllowPaging="true" >
        <asp:boundfield DataField="Title" HeaderText="Title">

and here's the code behind

SPList corrList = getSelectedList("Correspondance");
SPWeb web = SPContext.Current.Web;
SPList taskList = web.Lists["Tasks"];
SPTypes.List = taskList;
SPTypes.SelectCommand = "<Where><And><Eq><FieldRef Name=\"Title\"/>" +
        "<Value Type=\"Text\">Document interne</Value></Eq><Eq><FieldRef Name=\"Fonction\"/>" +
        "<Value Type=\"Text\">GenerateChrono</Value></Eq></And></Where>";

GV.DataSource = SPTypes;

I checked the query and it returns many items I even tried to put the query this way :

SPTypes.SelectCommand = "<Query><Where><And><Eq><FieldRef Name=\"Title\"/>" +
        "<Value Type=\"Text\">Document interne</Value></Eq><Eq><FieldRef Name=\"Fonction\"/>" +
        "<Value Type=\"Text\">GenerateChrono</Value></Eq></And></Where></Query>";

PS title is the internal name I want to retrieve !

share|improve this question
Glolita, try using SPGridView instead – Arsalan Adam Khatri Nov 7 '12 at 13:51
up vote 2 down vote accepted


Use SPGridView instead of ASP:GridView...

Here is a nice article: How to use the SPGridView filter together with a SPDataSource

I also noticed in every example in CAML before <Query> they are using <View>, but I don't know if this is really the problem... can you please try that as well



Hope this resolves the issue!

share|improve this answer
it still display nothing ! – Glolita Nov 7 '12 at 14:03
I just edited the answer, follow the Blog given! – Arsalan Adam Khatri Nov 7 '12 at 14:04
yeah I noticed that too and I tried to put <view> as well and also nothing ! – Glolita Nov 7 '12 at 14:06
set SPTypes.DataSourceMode="List" – Arsalan Adam Khatri Nov 7 '12 at 14:09
Glolita, Samples on how to use SharePoint's GridView - I hope this will answer all your questions.. I am glad it helped! – Arsalan Adam Khatri Nov 8 '12 at 9:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.