CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 4/29/2004 1:27:22 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 6 Views: 243 Favorited: 0 Favorite
7 Items, 1 Pages 1 |< << Go >> >|
NeoAdroit
Asp.Net User
Link Button in the Header Template4/29/2004 1:27:22 PM

0

Im building a custom control datagrid, inherited from DataGrid. I add the template columns dynamically to the datagrid, in the onPreRender event, and i have dynamically added Link Buttons, in the HeaderTemplate of the Template Columns. But these LinkButtons doesnt seem so raise Click/any events. The ItemCommand handler, of the datagrid doesnt get invoked when i click the Linkbuttons in the header template (I dont have any special handlers for the linkbutton). Can any one identify the potential problem ?

thanks
Neo.
master4eva
Asp.Net User
Re: Link Button in the Header Template4/30/2004 7:14:42 AM

0

Have you set the CommandName property of these buttons? If not, that is the problem.
-- Justin Lovell
NeoAdroit
Asp.Net User
Re: Link Button in the Header Template4/30/2004 2:09:46 PM

0

I have set the ComamndName property of the LinkButtons in the Header Template. what else could be the issue ?

thanks
Neo
master4eva
Asp.Net User
Re: Link Button in the Header Template4/30/2004 3:23:52 PM

0

Damn it! Just saw the other issue: the other issue that could be the problem is that you are programmactically setting the template during PreRender. Try setting the template during the Init part of the life cycle.
-- Justin Lovell
NeoAdroit
Asp.Net User
Re: Link Button in the Header Template4/30/2004 8:55:29 PM

0

Bingo! The problem is because of, adding the template columns and the controls in it , on the pre-Render event of the grid. And it works if i have a control dynamically added in onInit event of the datagrid (As Dynamically added controls, should be added on the init event during the postback, to receive the events!!!!).

But Now, having discovered that! I couldnt solve my problem, In the OnInit event of the server control, i couldnt decide up on my dynamic template columns, this is because, the Datagrid's onInit fires before the Page_init() (is that correct ?)where i get my required information. Is there any way I could over come this ?

One more thing, If I add the Dyanmic Controls in the OnLoad event on the server control, I couldnt capture events. How different is OnLoad event of a server control from its onInit event? (In a Page, the dynamic controls loaded in the Page_Load can fire events)

thanks
Neo


master4eva
Asp.Net User
Re: Link Button in the Header Template5/2/2004 7:40:22 AM

0

:: Datagrid's onInit fires before the Page_init()

That is correct. What you can do instead is move everything to the OnLoad method.

:: How different is OnLoad event of a server control from its onInit event?

There is none other than timing. The problem that you could be having with your control events not firing is if you have the following code:

Button button = new Button();

Controls.Add(button);
button.Click += new EventHandler(...);

But that code is not safe. Instead, the code can be even safer if you switch two lines of code around:

Button button = new Button();

button.Click += new EventHandler(...);
Controls.Add(button);

The reason has to be that with the first one, you are adding the control to the control tree and giving it life. You are then attaching an event while it is running and the oppurtunity for that event to fire could have passed long time ago. However, in the second bunch of code, it ensures that it has the event attached before "running". That way, it is not a game of cat 'n mouse in the page life cycle.

Another problem that you could be having is that you adding your controls like this:

protected override OnLoad(EventArgs e) {
base.OnLoad(e);
// adding controls here
}

Or:

protected override OnLoad(EventArgs e) {
// adding controls here
}

Instead, the code should look something like this:

protected override OnLoad(EventArgs e) {
// adding controls here
base.OnLoad(e);
}

The explaination can be found on this page:

http://aspalliance.com/articleViewer.aspx?aId=345&pId=3
-- Justin Lovell
NeoAdroit
Asp.Net User
Re: Link Button in the Header Template5/3/2004 4:10:51 PM

0

thanks Justin for the detail reply.

I have taken care of the two situations you have noted, in which my control could lose the events. But still the problem is presistent. Now that Im running out of ideas why this is happening, the problem grows very wierd.

My code looks like this


Protected Overrides Sub OnLoad(ByVal e As EventArgs)
If _table Is Nothing Then
_table = TableFromViewState
End If
MyBase.OnLoad(e)
End Sub 'OnLoad

Protected Overrides Sub OnInit(ByVal e As EventArgs)
If Not (HttpContext.Current Is Nothing) Then
If _allowediting Then
Dim EditCol As New TemplateColumn
/* This Template colum contains Imagebuttons */
If _allowdeleting Then
EditCol.ItemTemplate = New EditTemplateColumn("Edit-Delete")
Else
EditCol.ItemTemplate = New EditTemplateColumn("Edit")
End If
EditCol.EditItemTemplate = New EditTemplateColumn("Update-Cancel")
MyBase.Columns.Add(EditCol)

End If
End If
MyBase.OnInit(e)
End Sub 'OnInit


In this case, the Image buttons in the EditCol Template Column, can sucessfully raise events and work as expected. But When i try to move the dynamic control EditCol to the Onload event of the control (which i require for adding some more dynamic controls, that are now added in prerender) , the whole things collapses. When the code looks like this


Protected Overrides Sub OnLoad(ByVal e As EventArgs)
If _table Is Nothing Then
_table = TableFromViewState
End If

If Not (HttpContext.Current Is Nothing) Then
If _allowediting Then
Dim EditCol As New TemplateColumn
/* This Template colum contains Imagebuttons */
If _allowdeleting Then
EditCol.ItemTemplate = New EditTemplateColumn("Edit-Delete")
Else
EditCol.ItemTemplate = New EditTemplateColumn("Edit")
End If
EditCol.EditItemTemplate = New EditTemplateColumn("Update-Cancel")
MyBase.Columns.Add(EditCol)

End If
End If

MyBase.OnLoad(e)
End Sub 'OnLoad

Protected Overrides Sub OnInit(ByVal e As EventArgs)

MyBase.OnInit(e)
End Sub 'OnInit



With this code, none of the Image buttons in the Editcol raise any events. Not only this even the link buttons in the Pager ( I have a simple Numeric Paging enabled in my grid) loses its functionality (not raising the events), infact there are no events raised on my grid with this code.
Not sure what goes wrong, when the Dynamic controls are added in the onLoad event ?

thanks
Neo.
7 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
The Definitive Guide to Interwoven TeamSite Authors: Brian Hastings, Justin McNeal, Pages: 537, Published: 2006
ASP.NET unleashed Authors: Stephen Walther, Pages: 1459, Published: 2003
Programming data-driven Web applications with ASP.NET Authors: Don Wolthuis, Donny Mack, Doug Seven, Pages: 704, Published: 2002
Beginning ASP.NET 1.1 with Visual C# .NET 2003 Authors: Chris Ullman, Books24x7, Inc, Pages: 0, Published: -1
Producing for the Web Authors: Jason Whittaker, Pages: 158, Published: 2000

Web:
Freebies Round-Up: Icons, Buttons and Templates | Graphics ... We've selected fresh high quality icons, buttons, vector graphics, templates and ... Glass Buttons and Bars, Web Page Elements, Header Designs and RSS-Icons. ..... Link [www.logobee.com]. There are nice templates of shiny orbs and ...
System.NullReferenceException when using the LinkButton in the ... NullReferenceException when using the LinkButton in the HeaderTemplate ... < HeaderTemplate>. ...
How to disable a LinkButton in a GridView Jan 19, 2009 ... Hi there I have a GridView on my page and if there are no rows returned from the database I add an empty row to force the GridView's headers ...
Link button in repeater header




...
ShareThis button/link using Advanced Template in Typepad ... ShareThis button/link using Advanced Template in Typepad (4 posts) ... 4)Place the following in your head tag and give it a shot. ...

Link Button in the Header Template - ng.asp-net-forum.windows ... Link Button in the Header Template, > ROOT > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum, Date: 4/29/2004 1:27:22 PM, ...
Nested Wizard Control: Having Sub-Steps in a 2.0 Wizard Control ... //While stepping through the code, the individual LinkButton's ... I have two buttons in the header template as I want to control the steps ...
CreateUserWizard and CustomNavigationTemplate Question - ng.asp ... I am using a link button (supports event bubbling? ... FeedbackID.Text = "Next button clicked"; } . ... the first step of the createuserwizard to a custom navigation template, and modified the . ...
GridView column data blanks in template field after using EDIT ... I have a gridview with data.Whenever i click the edit link button apper in separate ... CodeProject: Dynamically Adding Template columns to a GridView ... i ...
Looking for a collapsible vertical menu template - ng.asp-net ... Looking for a collapsible vertical menu template, > ROOT > NEWSGROUP > Asp.Net Forum ... link button visible by user roles ...

Videos:
Wordpress Theme on Steroids Wordpress is an easy to use blogging tool. Unfortunately, the base configuration and themes bundled with the software are less than desirable. Now ...
Human Computation Google TechTalks July 26, 2006 Luis von Ahn is an assistant professor in the Computer Science Department at Carnegie Mellon University, where ...
Subtererea Industry Vs Hip Hop
Literate functional testing Google London Test Automation Conference (LTAC) Google Tech Talks September 7th, 2006 Presenters: Robert Chatley and Tom White
django: Web Development for Perfectionists with Deadlines Google TechTalks April 26, 2006 Jacob Kaplan-Moss ABSTRACT Django is one of the premier web frameworks for Python, and is often compared ...






i cant make it work

css adapted treeview control displaying all nodes on page load

css friendly control adapters is not running with update panel of atlas

gridview adapter with pagertemplate broken

css treeview nested li question

css adapters ok on sharepoint desinger?

warning cssselectorclass

adapter for asp:image control

adjustable tabs in css adapters menu

staticselectedstyle in menu

menu not showing fly out menus

vista and visual studio 2005

could not load type 'cssfriendly.menuadapter'. (c:....\app_browsers\cssfriendlyadapters.browser line 4)

problem with aspnet-menu-selected friendly css menu

control must be in server form

menu works great in ie7, not in ie6

can writebegintag generate spaces instead of tabs?

centering issue with css friendly adapter and horizontal menu

cssfriendlyadapters with masterpages

use cssadapters in library

problems with horizontal orientation

formview bug + fix

webresource.axd

beginner problem

problem installing...

treeview populateondemand ajax style

another menu is not displaying in ie6 using css control adapters

menu underlines visited items in ie6 only

control adapter for a radiobutton, (stuck on the

css syntaz question

   
  Privacy | Contact Us
All Times Are GMT