Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1005595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:19:22+00:00 2026-05-16T08:19:22+00:00

I created a GridView in code with a DataTable as its data source which

  • 0

I created a GridView in code with a DataTable as its data source which worked fine. I have now moved the GridView creation into a .ascx file to make it easier to format.

For some reason this has started triggering the HttpParseException:

Databinding expressions are only
supported on objects that have a
DataBinding event.
System.Web.UI.WebControls.HyperLinkField
does not have a DataBinding event.

What’s changed to cause this difference and how do I fix it?

Original code:

// Set up columns for datagrid
var boundField = new HyperLinkField
                    {
                        HeaderText = "Title",
                        DataTextField = MembershipCollection.WebTitleColumnName,
                        DataNavigateUrlFields = new[] { MembershipCollection.WebUrlColumnName },
                        DataNavigateUrlFormatString = "{0}"
                    };

// Set up datagrid
_sitesList = new GridView
                {
                    AutoGenerateColumns = false,
                    AllowPaging = true,
                    PageSize = PageSize,
                    EmptyDataText = "No results",
                    Width = new Unit(100, UnitType.Percentage),
                    CellPadding = 2,
                    PagerSettings =
                        {
                            Visible = true,
                            Mode = PagerButtons.NextPrevious,
                            Position = PagerPosition.Bottom,
                            NextPageText = "Next >",
                            PreviousPageText = "< Previous"
                        }
                };
_sitesList.PagerStyle.HorizontalAlign = HorizontalAlign.Center;
_sitesList.RowDataBound += GridView_RowDataBound;
_sitesList.PageIndexChanging += GridView_PageIndexChanging;
_sitesList.Columns.Add(boundField);

.ascx code:

<asp:ObjectDataSource ID="_sitesDataSource" runat="server"
    SelectMethod="GetSites"
    TypeName="System.Data.DataTable" />
<asp:GridView ID="_sitesGridView" runat="server"
    AutoGenerateColumns="false"
    AllowPaging="true"
    PageSize="<%# this.PageSize %>"
    EmptyDataText="No results"
    width="100%"
    DataSourceID="_sitesDataSource"
    OnRowDataBound="GridView_RowDataBound"
    OnPageIndexChanging="GridView_PageIndexChanging">
    <PagerSettings Visible="true" Mode="NextPrevious" Position="Bottom" NextPageText="Next >" PreviousPageText="< Previous" />
    <PagerStyle HorizontalAlign="Center" />
    <Columns>
        <asp:HyperlinkField
            HeaderText="Title"
            DataTextField="<%# MembershipCollection.WebTitleColumnName %>"
            DataNavigateUrlFields="<%# MembershipCollection.WebUrlColumnName %>"
            DataNavigateUrlFormatString="{0}" />
    </Columns>
</asp:GridView>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:19:23+00:00Added an answer on May 16, 2026 at 8:19 am

    I just realised – I used <%# when it should have been <%= in the HyperlinkField declaration.

    <%# is going to try and data bind, and as the exception indicates there is no associated data binding for the HyperlinkField. However <%= will simply execute code (i.e. insert the text from a constant).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView to which I bind a dataTable that I manually created.
I have a GridView which is created dynamically at run-time (the code is in
I have created a gridview in code behind (as in its not physically present
I have a gridview that gets created in codebehind. In the below code, I
I have a datatable being built in code which can dynamically have any given
I have write this code to create a gridview with 3 columns DataTable dt
I have the following code which adds a label and a gridview to an
In the past, I have populated GridView's with 'manually created' data sources in the
I have a gridview to which I have created an Insert Template in the
I have created a gridview with a column of checkboxes. I want the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.