1

I have created an application page which displays 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=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, 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> <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <SharePoint:SPGridView ID="" runat="server" AutoGenerateColumns="false" </SharePoint:SPGridView> </asp:Content> <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server"> </asp:Content> <asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" > </asp:Content> 

CODE BEHIND:

private void BindGrid() { try { 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; gvCafe.DataBind(); private void GetDetails(SPWeb web, SPListItemCollection coll) { if (coll.Count > 0) { row = table.Rows.Add(); //SetDefaultImage(web); row["INDEX"] = 1; row["ENTRY"] = SPUtility.ConcatUrls(coll[0].Web.Url, coll[0].Url); } } 
6
  • 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 ":( Commented Oct 25, 2011 at 11:00
  • It would be helpful if you included the code and the error you are receiving. Commented Oct 26, 2011 at 14:28
  • i dnt get any error as such.code runs but the grid isnt rendering Commented Oct 31, 2011 at 6:39
  • 1
    @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! Commented Oct 31, 2011 at 11:38
  • 1
    The code sample is incomplete? Looks like one and a half functions. I don't see where you populate table at all. Commented Oct 31, 2011 at 13:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.