Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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"> 
</SharePoint:SPDataSource> 
<asp:gridView ID="GV" runat="server" DataKeyNames="Title"  AutoGenerateColumns="False" AllowPaging="true" >
    <columns>
        <asp:boundfield DataField="Title" HeaderText="Title">
        </asp:boundfield>
    </columns>
</asp:gridView>

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;
GV.DataBind();

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

1 Answer 1

up vote 2 down vote accepted

Glolita,

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

Also,

SPTypes.DataSourceMode="List"

Hope this resolves the issue!

share|improve this answer
    
it still display nothing ! –  Glolita Nov 7 '12 at 14:03
1  
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
2  
set SPTypes.DataSourceMode="List" –  Arsalan Adam Khatri Nov 7 '12 at 14:09
1  
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

 
discard

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.