[quoted text, click to view] > 1) Have you attempted to do a step by step debugging to determine if in fact
> your btnTier_Command function is being invoked?
Yes, I have and yes, it is. If there is a way for the debugger to show me
what invoked the event, then I am not deft enough to find it.
[quoted text, click to view] > 2) Does this happen when you first load this page?
No. When I first load the page, no product information is loaded as per
design. The user has to choose which of many products he wants to see
account info for. If I choose a product that has an account with button then
the "phantom event" occurs the first time those accounts are loaded. If I
reload the same product, it does not occur again. If I switch to another
product then it happens the first time, but not subsequently. If I switch
again to the previous product, or to another, then the same behavior occurs.
[quoted text, click to view] > 3) That is the base class of AccountTier?
public class AccountTier : System.Web.UI.WebControls.WebControl
[quoted text, click to view] > Coding question for my own curiosity: Why are you dynamically creating the
> controls? (Buttons and AccountTier).
I needed buttons in the datagrid when I don't know how many rows there will
be or whether the data in that particular row warrants a button or a textbox.
It seemed the best way to accomplish the goal. How should I have done it?
As for the AccountTier, it just seemed like a good idea at the time. The
only time I want to see the AccountTier control is when I click on a button
on the data grid. I just figured, why spend the resources to create it when
I didnt need it.
[quoted text, click to view] > Steve
>
>
>
>
>
> "John Bankhead" <JohnBankhead@discussions.microsoft.com> wrote in message
> news:3738F103-7F4E-4DF7-99E7-8E3F0D16D7A2@microsoft.com...
> > Top of page: Listbox and button. Listbox contains a list of products.
> > Button says "Load". Beneath both is a datagrid. In the datagrid, 25
> > columns
> > contain text and one of the columns contains a textbox or button depending
> > on
> > the nature of the account. Clicking a button in this column causes a
> > round-trip to the server and another control to appear on top of the
> > datagrid
> > for more detailed info.
> >
> > Here is the problem: Loading the datagrid with a product which shows
> > buttons
> > will cause that detailed control to appear for the datagrid row to have a
> > button in that column. No clicking on the button is necessary. How is
> > the
> > command event for that button being invoked?
> >
> > All of the datagrid buttons are created in the ItemDataBound event for the
> > datagrid. Their command events are attached to "private void
> > btnTier_Command(object sender, CommandEventArgs e)" and each carries the
> > id
> > of its particular account in the CommandArgument attribute.
> >
> > from ItemDataBound event:
> >
> > if(e.Item.Cells[tieredColumn].Text=="TIERED"){
> > b = new Button();
> > b.ID = "revprice_" + Counter.ToString();
> > b.Text = e.Item.Cells[RevPriceCol].Text;
> > b.Width = Unit.Pixel(58);
> > b.BackColor = bModded? Color.FromArgb(220, 248, 217) : Color.LightGray;
> > b.ForeColor = bException? Color.Red : Color.Black;
> > b.CommandArgument = e.Item.Cells[AcctCol].Text;
> > b.CommandName = "btnTier";
> > b.Command+=new CommandEventHandler(btnTier_Command);
> > b.Enabled = bExclude;
> > e.Item.Cells[RevPriceCol].Controls.Add(b);
> > }
> >
> > -------------------
> > private void btnTier_Command(object sender, CommandEventArgs e){
> > int acct = Convert.ToInt32(e.CommandArgument);
> > AccountTier tier = new AccountTier(acct, Decision, dstConnectionString);
> > tier.ID = "tiered";
> > tier.Attributes.Add("style",
> > "z-index:300;position:absolute;top:125;left:100;");
> > this.Controls.Add(tier);
> > }
> >
> > --
> > John Bankhead
>
>