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); } }
tableat all.