S
Solomon Shaffer
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 );
}
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 );
}