J
jarod
Hello,
I'm having difficulty with trying to extend the
functionality of the DataGrid Control. I created the
child class, but can't figure out how to access all the
functionality of the DataGrid class form the aspx file.
When using the <asp:TemplateColumn> tag, I get the
following error:
Description: An error occurred during the parsing of a
resource required to service this request. Please review
the following specific parse error details and modify your
source file appropriately.
Parser Error Message: Type 'DDW.DDWDataGrid' does not have
a property named 'asp:TemplateColumn'.
--------------------------------------------------------
-------------- cs file -------------------------------
--------------------------------------------------------
// DDWDataGrid.cs
//
namespace DDW {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Data;
/// <summary>
/// Summary description for DDWDataGrid.
/// </summary>
public class DDWDataGrid :
System.Web.UI.WebControls.DataGrid {
/// <summary>
/// Creates a new instance of DDWDataGrid
/// </summary>
public DDWDataGrid() : base() {
}
protected override void Render
(HtmlTextWriter output)
{
output.Write( "overide!" );
base.Render(output);
}
}
}
--------------------------------------------------------
-------------- aspx file -------------------------------
--------------------------------------------------------
<%@ Page Language="C#" autoeventwireup="True" %>
<%@ Register TagPrefix="DDW" NameSpace="DDW"
Assembly="DDWDataGrid" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
Random Rand_Num = new Random();
dt.Columns.Add(new DataColumn("IntegerValue",
typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue",
typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue",
typeof(double)));
for (int i = 0; i < 15; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * Rand_Num.Next(1, 15);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
dv.Sort=SortExpression;
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
ItemsGrid.DataSource = CreateDataSource();
ItemsGrid.DataBind();
}
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<h3>DataGrid Sorting Example
</h3>
<DDWDWDataGrid id="ItemsGrid" runat="server"
BorderColor="black" BorderWidth="1" CellPadding="3"
AllowSorting="true" OnSortCommand="Sort_Grid"
OnEditCommand="Edit_Grid" HeaderStyle-BackColor="#00aaaa"
ShowFooter="True" AutoGenerateColumns="true">
<asp:TemplateColumn>
<HeaderTemplate>
<b> IntegerValue </b>
</HeaderTemplate>
</asp:TemplateColumn>
</DDWDWDataGrid>
</form>
</body>
</html>
I'm having difficulty with trying to extend the
functionality of the DataGrid Control. I created the
child class, but can't figure out how to access all the
functionality of the DataGrid class form the aspx file.
When using the <asp:TemplateColumn> tag, I get the
following error:
Description: An error occurred during the parsing of a
resource required to service this request. Please review
the following specific parse error details and modify your
source file appropriately.
Parser Error Message: Type 'DDW.DDWDataGrid' does not have
a property named 'asp:TemplateColumn'.
--------------------------------------------------------
-------------- cs file -------------------------------
--------------------------------------------------------
// DDWDataGrid.cs
//
namespace DDW {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Data;
/// <summary>
/// Summary description for DDWDataGrid.
/// </summary>
public class DDWDataGrid :
System.Web.UI.WebControls.DataGrid {
/// <summary>
/// Creates a new instance of DDWDataGrid
/// </summary>
public DDWDataGrid() : base() {
}
protected override void Render
(HtmlTextWriter output)
{
output.Write( "overide!" );
base.Render(output);
}
}
}
--------------------------------------------------------
-------------- aspx file -------------------------------
--------------------------------------------------------
<%@ Page Language="C#" autoeventwireup="True" %>
<%@ Register TagPrefix="DDW" NameSpace="DDW"
Assembly="DDWDataGrid" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
Random Rand_Num = new Random();
dt.Columns.Add(new DataColumn("IntegerValue",
typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue",
typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue",
typeof(double)));
for (int i = 0; i < 15; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * Rand_Num.Next(1, 15);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
dv.Sort=SortExpression;
return dv;
}
void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
ItemsGrid.DataSource = CreateDataSource();
ItemsGrid.DataBind();
}
}
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<h3>DataGrid Sorting Example
</h3>
<DDWDWDataGrid id="ItemsGrid" runat="server"
BorderColor="black" BorderWidth="1" CellPadding="3"
AllowSorting="true" OnSortCommand="Sort_Grid"
OnEditCommand="Edit_Grid" HeaderStyle-BackColor="#00aaaa"
ShowFooter="True" AutoGenerateColumns="true">
<asp:TemplateColumn>
<HeaderTemplate>
<b> IntegerValue </b>
</HeaderTemplate>
</asp:TemplateColumn>
</DDWDWDataGrid>
</form>
</body>
</html>