Reputation: 219
asp.net noob here. I'm trying to override/extend Gridview for paging as specified in this topic: Problem with Efficient Gridview paging without datasource control
code-behind:
namespace MyCode
{
public partial class _Default : System.Web.UI.Page
{
....
}
}
namespace cly.Web.CustomControls
{
public class clyGridView : GridView
{
...code
}
}
How would I declare this new gridview in my .aspx file? I have tried using the class as
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyCode._Default" %>
<%@ Import Namespace="cly.Web.CustomControls" %>
...
<asp:clyGridView ID="MyResults" runat="server"> </asp:clyGridView>
but that doesn't work and I get this error
The type or namespace name 'clyGridView' does not exist in the namespace 'System.Web.UI.WebControls' (are you missing an assembly reference?)
Upvotes: 1
Views: 2083
Reputation: 17724
If your goal is only to make the paging efficient, you should only create a custom datasource.
Here is a tutorial that teaches you how to do it.
Creating a custom girdview is not needed.
If you implement the datasource properly, gridview will bind to it perfectly and you will get the efficient paging you desire.
Upvotes: 0
Reputation: 18062
You need to register a tag prefix for your custom control.
Add
<%@ Register tagprefix="cly" namespace="cly.Web.CustomControls" %>
to your page and use the tag prefix with your custom control
<cly:clyGridView ID="MyResults" runat="server"> </cly:clyGridView>
Upvotes: 2