Adding controls to a Custom DataGrid Server Control

Edited by SomeNewKid. Please post code between <code> and </code> tags.

I'm working on creating my own customized datagrid control. I've created a class which inherits "System.Web.UI.WebControls.DataGrid" and when I add my new datagrid control library to my project it seems to work nicely. Now I want to add some submit buttons to appear at the bottom of my datagrid control. How do I do this? Sorry, I'm a bit of a newbie at server controls. Here's what I've tried:
Public Class UberDataGrid

Inherits DataGrid
Private MyButton As Button
Private Sub UberDataGrid_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Init
Me.AllowPaging = True
Me.PagerStyle.Mode = WebControls.PagerMode.NumericPages
Me.PageSize = 10
MyButton=New Button
End Sub
End Class

When I do this I get the datagrid ok, but no button. I didn't really expect this to work :), but I'm not sure how to add controls to my custom data grid control.
I think I could probably do it by creating a new custom control which adds the custom datagrid control and the button to it like the following:
    Public Class MyDataGridControl

Inherits Control
Implements INamingContainer
Private MyButton As Button
Private MyGrid As UberDataGrid
Protected Overrides Sub CreateChildControls()
'Add the custom datagrid and button here
End Sub
End Class

But when I do this, I'm not sure how to access the datagrid's template information. What I mean is in the first example I could do this in my aspx page:
<cc1:UberDataGrid id="" DataSource="".....>


But In the second example I don't know how to create the template information of the custom datagrid. Can anyone help me?
12/6/2004 10:36:26 PM 4216 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 21


Similar Artilces:

Usercontrol vs Custom Server Controls, Any need for Custom Server Controls
Hello I'm new to ASP.Net so this is probably a stupid question but, is there any need to create customer server controls now that you can pre-compile usercontrols into a dll and thus easily share between applications? This blog post from David Ebb describes how to do it and the restrictions he note don't seem that bad (other than being able to embed resources such as images in the dll). His article desribes the techniques for ASP.Net 2.0 and he suggests that there will be further improvements in .Net 3.5 in this ar...

how to have both server controls and html controls rendered in a custom control?
I have a custom control in which there is an html text box.when you click on it , a div containing a table is appeared and according to what you select in that table a text is set to the text box. It works fine but the problem is: as the text box is an html element it doesn't have viewstate and when a post back occures in the page its value disappeares.I tried a hidden field to keep its value.again there is another problem : I put this custom control in a usercontrol and put the usercontrol in a multiview and by clicking on a button this view is selected and by clicking another bu...

problems listenening to events on a custom server control from another custom server control
 Hi all,I am having problems listening to events on one of custom server controls(AddBookmark) from another custom server control(BookmarkList). The listener or the BookmarkList control has a property that can be set to the AddBookmark control (string at design but the reference is obtained at run-time). I am able to get a reference to the AddBookmark control and add a listener to it on the BookmarkList control on the OnPrender of BookmarkList. But the problem is that when the events on AddBookmark gets fired, the listener added from the BookmarkList is no longer present and the listene...

Custom Server Control Vs Web Parts, Any need for Custom Server Control
Hello I've just posted a similar question on why you need server controls when you can pre-compile usercontrols and redistribute them. I've seen lots of (usercontrol vs web part) but not much on web part vs custom server control. According to the MSDN site you can put web parts onto a normal page outside of a web part zone and they behave just like custom server controls. So, if you are creating a bunch of controls for redistribution to customer sites and/or SharePoint sites why don't you just create Web Par...

Custom Server Control Made of Custom Controls?
I'm giving myself a crash course in custom server controls, and I have a quick general question. Can I have a custom server control that is composed of other server controls I created. I'm pretty sure the answer is yes, but I want to be positive. Yes Shows how to combine existing controls into a new control using class composition. -ron Thanks! ASP.NET so rocks! Making page components extensible objects is such a great idea! I love it....

Adding control to custom control
Is it possible to add a control (e.g. a LinkButton) to a custom control I'm programming? Basically, I'm making a file browser custom control. I have a property called Path which has the absolute path to the folder the user is browsing. I can get all the folders and files to list easily. However, I want the folder names to be links which, when clicked, will change the path to the currently clicked folder. Is this possible? Yes, it is. What you are looking at is called composite controls. I have written an article on this which you may read over here: Ju...

Custom Control within a Control Control
I am developing a custom controls that will render headers for different web sites. Within these controls, I want to place another custom control that will change the language. I created the language control and had it implement IPostBackDataHandler. This control works fine if I drag it on a new web form, but if I tell a header custom control to render it problems occur. The Language Selector custom control does not have a Page member anymore and the event handlers do not work. Does anyone have any experience with doing something similiar? Anyone have any suggestions? Thanks, ...

Templated Custom Control not updating host designer.cs file with child server control variables.
Hello, I have a custom web control that acts as a collapsable gradient header and containter all in one. I followed the MS example closly and got a decent control that works well. But then I ran into a problem, if I add another nested server control to the content area of my custom control on any given page, it doesn't add the protected cooresponding variabe in the pages designer code module. Below is an example of the problem, in the page TestPage.aspx the nested control "TextBox1" should show up in the TestPage.aspx.designer.cs but does not. I have a feeling that this ha...

Adding a custom ItemTemplate to a custom DataGrid control
The following article shows how to create a custom ItemTemplate for a custom repeater control: Does anyone know how to do this for the ItemTemplate of a DataGrid control? Same story :-) . Instead, let me give you a whiz on how the DataGrid would work (from cut and past and adapt): public class CustomItemTemplate : ITemplate { private DataGrid grid; public void InstantiateIn(Control container) { Label label = new Label(); label.DataBinding += new EventHandler(LabelDataBounded); ...

adding custom properties to a custom server control
1.  I want to add a public property to a custom server control.  the property is called Search Type and the possible choices that will appear in the properties window from the page would be client, provider, vendor and service.  I want this property to function much like the border style property works for an button. 2.  My second question would be how do I add a section to the properties window?  What i mean is for this custom server control, i want to add a section called Search Features much like the appearance or behavior sections for an ...

how to raise server control event(control defined inside user control) from host page?
I have built a user control(using c#,net 2.0,VS2005,MS-SQL server 2005),which contains set of 3 button,save,cancel and next and wud be reused/displayed in multiple pages.As the name says,they are suppose to update on save,reset the fields   on cancel and navigate to another page on next.How do i raise the onClick event for all of these button individually,from the individual host page?I do not have/do not prefer any logic,event handler etc.. defined in the user control for these buttons,since every host page have different set of parameters for save,cancel etc.Thanks...

Adding controls to a User Custom Control
I have a user custom control I'm trying to make and I want to add three drop down boxes.  What's the correct way to add these three items?  I've been looking for a tutorial or a hint on the internet for awhile and I can't find anything. ...

Adding a custom control in an user control
Hi there,I'm having problems in adding a custom control to a user control. When I Register the control in a aspx Page there is no problem but when I'm adding the control to the ascx Control then the error " File or assembly name WC.MyControl, or one of its dependencies, was not found." occurs. I really don't know what I'm doing wrong, or maybe I'm not doing at all.Here is my codeWebForm1.aspx:<%@ Register Tagprefix="wc" Tagname="XmlMenuControl" Src="XmlMenuControl1.ascx" %><%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="ASPNETPage.WebForm1" %&g...

Custom Server Control with Child Controls
I have a custom server control <xx.Parent... /> which parses custom child controls <xx.Child... />. In Visual Studio 2008, IntelliSense shows me both when I start typing my control namespace. How can I prevent the child control from showing up in IntelliSense  unless I'm adding it within the parent tags?Thanks. --Rudy...

Web resources about - Adding controls to a Custom DataGrid Server Control -

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Amazon takes control of delivery with thousands of semi truck trailers
As Amazon looks for new ways to speed up delivery, the company on Friday announced the purchase of thousands of semi truck trailers. The Seattle-based ...

The awkward pivot from gun control to terrorism.
... and even before the cops killed Syed Farook and Tashfeen Malik, many commentators and politicos plugged in their usual call for gun control. ...

more pics from Ground Control Touring 15th anniversary: Woods, Kurt Vile, Parquet Courts, Beach Fossils ...
... Parquet Courts / Woods & Kurt Vile / Beach Fossils @ Webster Hall 12/2/2015 We already posted a review and set of pictures from Ground Control ...

Robinson: Quickest Way To Force Gun Control? Form A ‘Black Rifle Association’
Robinson: Quickest Way To Force Gun Control? Form A ‘Black Rifle Association’

Open thread for night owls: First U.S. birth control clinic lasted just 10 days before being raided
... Parenthood Only Lasted for 10 Days but Started a Revolution . An excerpt: During her time in Europe, Sanger had seen Norwegian birth control ...

Watch a 4-year-old drive a dump truck by remote control
To prove the toughness of its latest FMX truck, Volvo turned it into an RC racer and handed the "keys" to the luckiest 4-year-old ever. The results ...

Amy Schumer 'Heartbroken' Over Failure of Gun Control Legislation
The comedian reacts to the Senate voting down a gun bill on Thursday.

Facebook Gives Users More Control Over Viral Content In News Feed
Facebook is updating its algorithm to give users more control over how high viral content appears in their News Feed.

BUSINESS IS BOOMING Firearm buys likely to spike amid gun control push
BUSINESS IS BOOMING Firearm buys likely to spike amid gun control push

Resources last updated: 12/5/2015 11:11:38 AM