Can I use command buttons on WHDG rows? I don't see any support for that in the tags or docs.
Hi,
Here is some VB code I have in one of my systems which catches a checkbox_changed event which is set to autopostback=true and it get's the row information from that event. It should work the same way for command buttons in the click event, etc. Once you have the row, you should be fine. You would have to shut Ajax off of the grid and wrap it in an updatepanel for this to work nicely.
Dim chk As CheckBox = DirectCast(sender, CheckBox)Dim row As New Infragistics.Web.UI.GridControls.GridRecordrow = DirectCast(DirectCast(DirectCast(DirectCast(DirectCast(chk.Parent, System.Web.UI.Control), Infragistics.Web.UI.TemplateContainer).Item, System.Object), GridControls.GridRecordItem).Row, GridControls.GridRecord)
Maybe it's an option.
Ed
At this point dynamic must be the problem, I'm working on an alternative solution because I'd truly prefer it to happen dynamically because it inherits from a custom control I created using the WHDG
Thanks for your reply!
When we did it, it was with a templated column which was defined in the markup, not dynamically. Do you know if the handler has to be added after the column definition has happened. Maybe, it can't work at all dynamically?
I added the following and the even is still not firing
salesGrid.GridView.ItemCommand += new ItemCommandEventHandler(salesGrid_itemCommand);
public void InstantiateIn(Control container) { System.Web.UI.WebControls.ImageButton a = new System.Web.UI.WebControls.ImageButton(); arg = (String)DataBinder.Eval(container, "DataItem." + arg).ToString(); a.ImageUrl = imageURL; a.CommandName = commandName; a.CommandArgument = arg; a.EnableViewState = true; a.CausesValidation = true; //a.Text = display; a.ID = arg; //a.Command += serverEvtHandler; //a.Click += serverEvtHandler; a.AlternateText = display; container.Controls.Add(a); } This is the event handler that I keep the debug set on and it never gets here protected void salesGrid_itemCommand(object sender, HandleCommandEventArgs e) { if (sender is ImageButton) { ImageButton source = (ImageButton)sender; String id = source.ID; } } Not sure what to do I feel like I tried everything BTW it is a WHDG
public void InstantiateIn(Control container) { System.Web.UI.WebControls.ImageButton a = new System.Web.UI.WebControls.ImageButton(); arg = (String)DataBinder.Eval(container, "DataItem." + arg).ToString(); a.ImageUrl = imageURL; a.CommandName = commandName; a.CommandArgument = arg; a.EnableViewState = true; a.CausesValidation = true; //a.Text = display; a.ID = arg; //a.Command += serverEvtHandler; //a.Click += serverEvtHandler; a.AlternateText = display; container.Controls.Add(a);
}
This is the event handler that I keep the debug set on and it never gets here protected void salesGrid_itemCommand(object sender, HandleCommandEventArgs e) { if (sender is ImageButton) { ImageButton source = (ImageButton)sender; String id = source.ID; } }
Not sure what to do I feel like I tried everything BTW it is a WHDG
Hello ,
You can add ItemCommand in the following way :
whdg1.GridView.ItemCommand +=
new Infragistics.Web.UI.GridControls.ItemCommandEventHandler(whdg1_ItemCommand);
Let me know if you need more assistance regarding this.