473,414 Members | 2,019 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,414 software developers and data experts.

Attaching events to templated controls

AC
I've created a user control (ASCX) that contains two buttons. This control is programatically placed into a datagrid via the LoadTemplate method and the TemplateColumn object. What I'd like to do is attach events to the two buttons from the code that loaded the object... like so (any ideas... I know FindControl won't work... just don't/can't create the events from within the sort column):

SortColumn.ascx
<asp:button id="SortUp" runat="server" text="up" CommandName="SortUp"></asp:button>
<asp:button id="SortDown" runat="server" text="down" CommandName="SortDown"></asp:button>

ProgramaticDataGrid.aspx.cs
ITemplate sortColumnTemplate = Page.LoadTemplate("~/Controls/Templates/SortColumn.ascx");

// below doesn't work, but you see where i'm going
Button bUp = (Button)sortColumn.FindControl("SortUp");
bUp.Click += //event handler code
// above doesn't work, but you see where i'm going

TemplateColumn tc = new TemplateColumn();
tc.HeaderText = "Sorting";
tc.ItemTemplate = sortColumnTemplate;
DataGrid1.Columns.Add(tc);
// binding code next
Nov 18 '05 #1
0 853

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

Similar topics

5
by: knocte | last post by:
Hello. I am a web developer very worried about "bloat code" and "languages mixture". So, since some time, I always try to avoid completely the use of javascript in XHTML/HTML files. This leads...
2
by: | last post by:
Hello All, I am having a lot of difficulty trying to bind a templated column, that is programmatically created for a datagrid, to a datasource column. I have a datasource containing 2 columns,...
0
by: Jeff Dockman | last post by:
Background: We needed the ability to create a templated web site that may change in layout from installation to installation. To accomplish this, we created a base Page class that all pages in...
1
by: Hasani \(remove nospam\) | last post by:
The way the system works is, you create a user control (ascx) that will be a template and must implement the interface IPageTemplate. You then create one or more user controls (ascx) that implement...
5
by: | last post by:
I am wondering what the best method of attaching custom Events to custom WebUserControls are. I cannot seem to find the proper terminology to expand my research. Basicallly I have a custom user...
1
by: Chris Newby | last post by:
I have a very basic custom control that exposes an ITemplate property and everything seems pretty straight forward so far. But, when I put other server controls intro the template section of my...
0
by: JohnyStyles | last post by:
I have a templated user control which looks like this: ----------------------------------------------------------------- <uc:MyUserControl runat=server> <TemplateProperty> </TemplateProperty>...
0
by: Mike | last post by:
Hi. I can't figure out why a button's click event is not firing in a templated control I've created (first time I've tried creating one). Please can someone help? On a point of lesser importance,...
0
by: David Rees | last post by:
Before I was using LoadControl and a slew of User Controls to achive the same effect, but I realised a custom TemplatedControl was the better way of doing it. Anyway, this is the templated...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.