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 have created an application page which display data from the list . I am able to see dropdown and labels server control./ but when i try to bind the list data to the SPgrid view , nothin gets rendered. below is the application page code : ASPX:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="" Inherits="" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">


<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">

<SharePoint:SPGridView ID="" runat="server" AutoGenerateColumns="false" </SharePoint:SPGridView>

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">


<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >



private void BindGrid()
         using (SPSite site = new SPSite(SPContext.Current.Site.Url))

         using (SPWeb web = site.OpenWeb())

              //Creation of data table
              table = new DataTable();
              table.Columns.Add("INDEX", typeof(Int32));
              table.Columns.Add("ENTRY", typeof(string));

                                      string dayOfWeek = DateTime.Now.DayOfWeek.ToString();
                                      SPList list = site.RootWeb.Lists["Cafeteria"];

              //Query to get the Entress items with Price big
              SPQuery query = new SPQuery();
              query.Query = "<Where><And><Eq><FieldRef Name='Day' /><Value Type='Choice'>" + dayOfWeek + "</Value></Eq><Eq><FieldRef Name='Type' /><Value Type='Choice'>etr</Value></Eq></And></Where><OrderBy><FieldRef Name='PrBig' Ascending='False' /></OrderBy>";
              SPListItemCollection coll = list.GetItems(query);

              GetDetails(web, coll);

              gvCafe.DataSource = table;

private void GetDetails(SPWeb web, SPListItemCollection coll)
    if (coll.Count > 0)
         row = table.Rows.Add();
         row["INDEX"] = 1;
         row["ENTRY"] = SPUtility.ConcatUrls(coll[0].Web.Url, coll[0].Url);
share|improve this question
i have visual webpart where it works but when i try to work with application page it doesnt throw me any error but it doesnt render the spfridview ":( – Nikhil Jangle Oct 25 '11 at 11:00
It would be helpful if you included the code and the error you are receiving. – Kit Menke Oct 26 '11 at 14:28
i dnt get any error as such.code runs but the grid isnt rendering – Nikhil Jangle Oct 31 '11 at 6:39
@Nikhil what Kit ment was please add more context to the question, such as code that works, code that throws the error, the error in question. As Q is now, it is not answerable and will be deleted. Also a comment like "send me some links" isnt likely to get much love from our audience: do your homework, give us something to work with, and eventually we can help you. Thanx! – Anders Rask Oct 31 '11 at 11:38
The code sample is incomplete? Looks like one and a half functions. I don't see where you populate table at all. – Kit Menke Oct 31 '11 at 13:59

Your Answer


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

Browse other questions tagged or ask your own question.