Click here to Skip to main content
16,020,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a requirement to display the SP 2013 List items in Gridview using caml query

C#
qry.Query =
                @"<Where>
                              <And>
                                 <And>
                                    <And>
                                       <Eq>
                                          <FieldRef Name='Resource' />
                                          <Value Type='Integer'>
                                             <UserID />
                                          </Value>
                                       </Eq>
                                       <Eq>
                                          <FieldRef Name='Year' />
                                          <Value Type='Text'>" + Year + @"</Value>
                                       </Eq>
                                    </And>
                                    <Eq>
                                       <FieldRef Name='Month' />
                                       <Value Type='Text'>0" + TimeSheetMonth + @"</Value>
                                    </Eq>
                                 </And>
                                 <Eq>
                                    <FieldRef Name='Status' />
                                    <Value Type='Choice'>Open</Value>
                                 </Eq>
                              </And>
                           </Where>";
 
qry.ViewFields = @"<FieldRef Name='ID' /><FieldRef Name='RequestID' /><FieldRef Name='Title'/><FieldRef Name='" + columnDay + "'/>";


In this query Columnday will get changed based on user selection (ex: 01,02,03 etc)

<asp:TemplateField HeaderText="RequestId">
<ItemTemplate>
<asp:Label ID="LabelRequest" runat="server" Text='<%# Bind("RequestId") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Font-Bold="True" HorizontalAlign="Left" Width="120px" Wrap="True" />
</asp:TemplateField>


<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<asp:Label ID="LabelRequest" runat="server" Text='<%# Bind("RequestTitle") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Font-Bold="True" HorizontalAlign="Left" Width="120px" Wrap="True" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Hours Spent" ItemStyle-Width="10%">
<ItemTemplate>
<asp:TextBox ID="TxtHoursSpent" Text="" runat="server" MaxLength="4" Width="25" ></asp:TextBox>
</ItemTemplate>
<ItemStyle Width="10%"></ItemStyle>


I'm displayin 3 columns namely RequestId, Title and Day.
I have binded Id & Title using Text='<%# Bind("RequestId") %>' ,Text='<%# Bind("RequestTitle") %>'
but I don't knw to bind the third column since it is an user defined column its value is stored in columnDay. How can i put it in aspx code .

Kindly help me!!!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900