gridview.datasource array with 10 items of empty RRS feed

  • Question

  • Hi C# Experts,

    I get the error:

    System.InvalidOperationException: The data source for GridView with id 'grdCookies' did not have any properties or attributes from which to generate columns. Ensure that your data source has content. at System.Web.UI.WebControls.GridViewColumnsGenerator.CreateAutoGeneratedFields(Object dataObject, Control control) at System.Web.UI.WebControls.GridView.CreateColumns(PagedDataSource dataSource, Boolean useDataSource) at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) at ASP.logoff_aspx.Page_Load()

    Reason is indeed that the array items are just empty. There are 10 items.

    Can I check before assiging the data source if any of the items is not empty? there a way to do that without looping through the array?

         ArrayList colCookies = new ArrayList();
         grdCookies.DataSource = colCookies;

    • Moved by CoolDadTx Tuesday, November 28, 2017 9:05 PM ASP.NET related
    Tuesday, November 28, 2017 10:03 AM


  • Please post questions related to web development in the ASP.NET forums.

    Michael Taylor

    • Marked as answer by metallon123 Wednesday, November 29, 2017 8:34 AM
    Tuesday, November 28, 2017 9:05 PM

All replies