473,396 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

inherited DataGrid failed to render

Hi all,

I want to derive a class from DataGrid so that I can have
a label on the top.
But when I tried to add the control to my form, I got an
error "Specified cast is not valid" on the line:
base.Render(w); inside the Render function.

Thanks a lot.
Frank

Here is my simple code.
private void Page_Load(object sender, System.EventArgs e)
{

Grid2 g=new Grid2();
this.Form1.Controls.Add(g);
}

public class Grid2 : System.Web.UI.WebControls.DataGrid{
System.Web.UI.WebControls.Label label=new Label();
protected override void OnInit(EventArgs e) {
this.label.Text="label 1";
this.Controls.Add(this.label);
}
protected override void Render(HtmlTextWriter w) {
this.label.RenderControl(w);
base.Render(w);

}
}
Nov 16 '05 #1
0 982

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: alreva | last post by:
hi I have inherited from Datagrid Class and just add a new method there. while using this new inherited calss in a master-detail mode (master Grid and detail grid) I used a datatable as the master...
1
by: Turgeson | last post by:
I thought this would be relatively simple but apparently it is not. I'm trying to create a Custom Server Control class that will automatically build a grid that conforms with a style consistent in...
2
by: Frank | last post by:
Hi all, I want to derive a class from DataGrid so that I can have a label on the top. But when I tried to add the control to my form, I got an error "Specified cast is not valid" on the line:...
3
by: danc | last post by:
I have a datagrid with a checkbox and dropdown list in each row. Both set AutoPostBack to true and ItemCommand and OnSelectedIndexChanged events for these controls works fine when DataGrid is not...
3
by: Gene Hubert | last post by:
I've got a custom datagrid that inherits from the standard datagrid on a windows form. I expected that since it is an inherited object, protected properties from the standard datagrid would be...
0
by: Frank | last post by:
Hi all, I want to derive a class from DataGrid so that I can have a label on the top. But when I tried to add the control to my form, I got an error "Specified cast is not valid" on the line:...
4
by: dbuchanan | last post by:
Is the following behavior normal? Both the 'Protected sub' in the inherited form and the 'Private Shadows sub' in the derived form fires. My interpretation of MSDN help on the topic "Shadows"...
4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
2
by: | last post by:
Is it possible to use IE transition effects (e.g. progid:DXImageTransform.Microsoft.Fade(Duration=2)">) to smooth "classic" (IE non-ATLAS) datagrid paging? How do you wire up the transition effect...
0
by: arlie_maija | last post by:
Hey - I'm writing a control that contains a DataGrid, and I'm unable to get the update event to fire. When I click the update link, the edit event fires. heres the details... my control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.