473,386 Members | 1,712 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,386 software developers and data experts.

Wrong LinkButton Firing Event - Very Odd

This is very interesting - and odd. I have a number of LinkButtons
that are created in a custom data grid that I created. The purpose of
the LinkButtons is to provide alphabetical filtering functionality on
the grid. Therefore, a LinkButton is added for every letter of the
alphabet. I also have a numeric filter button and an "All" button that
removes the filter. All of the LinkButtons are wired up to the same
event called AlphaSelector_Click(object sender, System.EventArgs e).
The sender parameter is the object was clicked. In this case, the
LinkButton.

The problem is when I click one of the LinkButtons, it SOMETIMES
passes the wrong LinkButton in the event. This seems to happen only on
a few different letters. For instance, if I click the "A" LinkButton,
it may pass in the "M" LinkButton. If I click the "N" link, it may
think the "Z" LinkButton is clicked.

Like I said, this only happens maybe 20% of the time. The other times,
it works perfectly. I have included code below. Any ideas???

private void WriteAlphaSelector()
{
LinkButton oLinkButton;
LiteralControl oLiteralControl;

for ( int i = 65; i < 91; i++ )
{
char cTemp = (char)i;
oLinkButton = new LinkButton();
oLinkButton.Text = cTemp.ToString();
oLinkButton.CssClass = "datagrid-alphafilter";
oLinkButton.CommandArgument = cTemp.ToString();
oLinkButton.Click += new EventHandler(AlphaSelector_Click);

if ( this.FilterKey == cTemp.ToString() )
{
oLinkButton.Style.Add( "color", "red" );
}
Controls.Add( oLinkButton );
}

oLinkButton = new LinkButton();
oLinkButton.Text = "#";
oLinkButton.CssClass = "datagrid-alphafilter";
oLinkButton.CommandArgument = "Number";
oLinkButton.Click += new EventHandler(AlphaSelector_Click);

if ( this.FilterKey == "Number" )
{
oLinkButton.Style.Add( "color", "red" );
}
Controls.Add( oLinkButton );

oLinkButton = new LinkButton();
oLinkButton.Text = Knowlagent.Common.Util.Resources.GetResourceWord(
"All" );
oLinkButton.CssClass = "datagrid-alphafilter";
oLinkButton.CommandArgument = "";
oLinkButton.Click += new EventHandler(AlphaSelector_Click);
Controls.Add( oLinkButton );
}

private void AlphaSelector_Click( object sender, System.EventArgs e )
{
LinkButton oLinkButton = (LinkButton)sender;
this.FilterKey = oLinkButton.CommandArgument;
this.ChildControlsCreated = false;
OnGridStateChanged( sender, e );
}
Nov 18 '05 #1
0 1291

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

Similar topics

1
by: Bill | last post by:
I'm trying to dynamically build several linkbuttons and wire them up to a method called OnLinkClick . . . For the life of me, I don't understand why the code below isn't firing the event. ...
0
by: Glenn Owens | last post by:
OK, this should be simple but... I have a dynamically created DataGrid (which is a Composite Server Control that I've written - inheriting from the System.Web.UI.Webcontrols.DataGrid). The grid...
3
by: JoakimR | last post by:
Hello, I have a problem with events not firing. I've created a web user control which renders a calendar using a table control. In two cells I'm adding LinkButtons for "prev/next month". However,...
2
by: prashant khandalkar via DotNetMonster.com | last post by:
Hello everyone. I am using asp:linkbutton in my web page. But when i click on the linkbutton it is not firing the click event please help me. It's urget my email address is pkhandalkar@gmail.com....
1
by: Mantorok | last post by:
Hi I have a control generator that is creating controls on the fly, one of the controls is a LinkButton, the problem is that the Click event is not firing, any ideas? Example: private void...
1
by: alexmac262 | last post by:
Please forgive as I have never posted to a group before and this is my first attempt at getting help on the internet. Inside an update panel I have a linkButton in a Gridview control template...
6
by: Mel | last post by:
I have a website that allows the user to generate a new quote. When they are finished creating the quote, it brings them to the final page (called the Goodbye.aspx page) which just states the...
2
by: Mufasa | last post by:
I have code to dynamically generate some link buttons (It's not know how many are needed until runtime.) I am adding the linkbutton to a cell in a table and the adding works fine. It's firing of...
0
by: jeenajos | last post by:
Hi all, I dono wat happen to my code. It was working quite fine. But now link button click event is not firing. This linkbutton was used for navigation; first,next,previous,last. Can anyone...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...

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.