Nannette Thacker ShiningStar.net
<a href="http://weblogs.asp.net/nannettethacker/pages/senior-web-application-developer-consultant.aspx">ASP.net Web Application Development</a>
-
Find me on LinkedIn....
Find Nannette on LinkedIn.
-
Nested Repeater AddHandler ItemCommand Not Firing
For those of you who program mostly in code behind, like I do, I have a gotcha for a nested repeater addhandler.
The nested repeater is defined in the code in front:
<asp:Repeater ID="repTestKeyControl" runat="server">
Your nested repeater contains a button that needs to fire a click event, so you add a "CommandName."
<asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="cmdEdit" />
In the codebehind, you typically retrieve your nested repeater and add the handlers:
Dim repTestKeyControl As Repeater
repTestKeyControl = CType(e.Item.FindControl("repTestKeyControl"), Repeater)
AddHandler repTestKeyControl.ItemCommand, AddressOf repTestKeyControl_ItemCommand
AddHandler repTestKeyControl.ItemDataBound, AddressOf repTestKeyControl_ItemDataBound ' programmatically add the handler...
repTestKeyControl.DataBind() ' handlers must go before databind
You setup your ItemCommand:
Protected Sub repTestKeyControl_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs)
If e.CommandName = "cmdEdit" Then
End If
End Sub
But it doesn't fire. Your ItemDataBound fires, so why not the ItemCommand?
I mean, typically a non-nested repeater uses this event and it triggers via the Handles modifier:
Protected Sub repTestKeyControl_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles repTestKeyControl.ItemCommand
So why not a nested repeater? Well, I don't know why, but I know how to fix it. Add the handler in the code-in-front via the "OnItemCommand":
<asp:Repeater ID="repTestKeyControl" runat="server" OnItemCommand="repTestKeyControl_ItemCommand">
Now it works. Go figure. Hope that helps at least someone. -
Programmatic Menus: Optimize Your Menus in Code-behind
In this article, I want to show how you can setup your menus in code-behind and avoid redundancy. I recently inherited a web application with the menu system setup in the code-in-front. Each menu shared identical values, other than the visibility. Notice that numerous properties are defined more than once, above and below the MenuItems. What's as bad is that this entire block of code was repeated for 6 additional menus.
Example of Redundant, Bloated Menu Setup -
Storing and Retrieving Objects from View State - The Serializable Attribute
View State allows you to retain page property values, such as string and numeric types, between postbacks. You may also store class objects in View State, but you must first add the Serializable attribute. If you do not add the Serializable attribute, you will receive this error when trying to add the object to View State:
-
Filtering Parameters in a SQL 2008 Stored Procedure
Ash explains the concept of Filtering Parameters in a Stored Procedure in this blog post.
-
Using Icons in Web Design
Nathan Barry posted a new article on How To Use Icons To Support Content In Web Design.
-
Kudos to Telerik Support!
I have been using Telerik controls for about a year now. First, on a client site project, and then I licensed it for my own development needs as a consultant.
-
VB.NET to C# Conversion Hints, Tips and Gotchas
If you're a VB.NET developer learning C# or converting your VB code to C#, here are a few hints, tips and gotchas.
-
SQL Server 2008 Web Edition and Express Edition Errors Resolved
Since I had purchased the SQL Server 2008 Web Edition for my database server, I decided to also install it on my development box. But when I tried to install the Management Tools, it errored with:
-
Attributes.Add: Adding Javascript Click Events Programmatically in Code-Behind
I'm going to demonstrate how to add javascript events programmatically in codebehind using the Attributes.Add method. You may want to add your javascript attributes programmatically so that you can populate the values from a database.