R
RCorona
I have a page that builds one or more datagrids dynamically, each row on each
grid has a link button. As I build each grid I also set the event handler for
the grid to the same method. When the button is clicked the post back
happens, but the item command never fires. I tried to over ride the
OnBubbleEvent but to no avail.
Below is a snippet of the code. It is in a for loop that builds one to many
grids.
DataGrid dg = new DataGrid();
dg.EnableViewState = true;
dg.ItemCommand += new DataGridCommandEventHandler(dg_ItemCommand);
dg.AutoGenerateColumns = false;
BoundColumn dcPrgId = new BoundColumn();
dcPrgId.DataField = "ProgramId";
dcPrgId.Visible = false;
dcPrgId.ReadOnly = true;
dg.Columns.Add(dcPrgId);
TemplateColumn dcPayment = new TemplateColumn();
dcPayment.HeaderText = "Monthly Payment";
dcPayment.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
dcPayment.ItemTemplate = new FormatedItemTemplate("Payment",
"{0:c}");
dcPayment.ItemStyle.Width = new Unit("120px");
dcPayment.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
dg.Columns.Add(dcPayment);
ButtonColumn btnClosingCosts = new ButtonColumn();
btnClosingCosts.HeaderText = "Costs";
btnClosingCosts.HeaderStyle.HorizontalAlign =
HorizontalAlign.Center;
btnClosingCosts.ButtonType = ButtonColumnType.LinkButton;
btnClosingCosts.Text = "View Details";
btnClosingCosts.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
btnClosingCosts.CommandName = "Costs";
dg.Columns.Add(btnCosts);
dg.DataSource = vRates;
dg.DataBind();
grid has a link button. As I build each grid I also set the event handler for
the grid to the same method. When the button is clicked the post back
happens, but the item command never fires. I tried to over ride the
OnBubbleEvent but to no avail.
Below is a snippet of the code. It is in a for loop that builds one to many
grids.
DataGrid dg = new DataGrid();
dg.EnableViewState = true;
dg.ItemCommand += new DataGridCommandEventHandler(dg_ItemCommand);
dg.AutoGenerateColumns = false;
BoundColumn dcPrgId = new BoundColumn();
dcPrgId.DataField = "ProgramId";
dcPrgId.Visible = false;
dcPrgId.ReadOnly = true;
dg.Columns.Add(dcPrgId);
TemplateColumn dcPayment = new TemplateColumn();
dcPayment.HeaderText = "Monthly Payment";
dcPayment.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
dcPayment.ItemTemplate = new FormatedItemTemplate("Payment",
"{0:c}");
dcPayment.ItemStyle.Width = new Unit("120px");
dcPayment.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
dg.Columns.Add(dcPayment);
ButtonColumn btnClosingCosts = new ButtonColumn();
btnClosingCosts.HeaderText = "Costs";
btnClosingCosts.HeaderStyle.HorizontalAlign =
HorizontalAlign.Center;
btnClosingCosts.ButtonType = ButtonColumnType.LinkButton;
btnClosingCosts.Text = "View Details";
btnClosingCosts.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
btnClosingCosts.CommandName = "Costs";
dg.Columns.Add(btnCosts);
dg.DataSource = vRates;
dg.DataBind();