Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > ItemCommand on dynamically built DataGrid

Reply
Thread Tools

ItemCommand on dynamically built DataGrid

 
 
RCorona
Guest
Posts: n/a
 
      12-21-2004
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();


 
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
ItemCommand not working for Link Button on dynamically built grid RCorona ASP .Net Datagrid Control 1 01-01-2005 04:45 PM
ItemCommand on Dynamically built DataGrid not firing RCorona ASP .Net Datagrid Control 0 12-21-2004 06:21 PM
Accessing data from Dynamically built Datagrid PokerJoker ASP .Net Datagrid Control 0 08-27-2004 08:01 PM
DataGrid ItemCommand Event Mike ASP .Net 1 10-23-2003 11:52 PM
Re: why datagrid's itemcommand event fired when I press ENTER key in a TextBox Natty Gur ASP .Net 0 06-30-2003 05:39 AM



Advertisments