Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Wrong LinkButton Firing Event - Very Odd

Reply
Thread Tools

Wrong LinkButton Firing Event - Very Odd

 
 
Solomon Shaffer
Guest
Posts: n/a
 
      07-29-2004
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 );
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LinkButton click event not firing Mel ASP .Net 6 06-12-2007 01:23 PM
LinkButton event not firing Mantorok ASP .Net 1 02-21-2005 01:44 PM
Event not firing from dynamically added linkbutton JoakimR ASP .Net 3 01-08-2005 05:56 PM
asp.net linkbutton event not firing webdad3 ASP .Net Building Controls 1 07-07-2003 12:11 AM
asp.net linkbutton event not firing webdad3 ASP .Net Web Controls 0 07-05-2003 02:07 PM



Advertisments