A
Austin Bailey
I've got a DataGrid with a Template Column that I'm placing a ImageButton
in. I am assigning the CommandArgument in the ItemCreated Event on the
DataGrid but when I try clicking on the ImageButton and the ItemCommand
event fires the Command Argument is gone. I've even tried assigning the
ToolTip text on the ImageButton to be sure that the properties are being
assigned and the ToolTip does appear in the browser window. I've made sure
that the DataGrid isn't rebinding before the ItemCommand Event too.
I've tried getting the ImageButton reference in the DataGrid with:
ImageButton btnAdd = (ImageButton)e.Item.Controls[0].Controls[9];
and
ImageButton btnAdd = (ImageButton)e.Item.Cells[1].Controls[9];
and
ImageButton btnAdd = (ImageButton)e.Item.FindControl("btnAdd");
they all return the correct control to me.
I then assign the CommandArgument with:
btnAdd.CommandArgument = "48";
I can see in the Watch window that the command argument is there. I then
click the image button on the web page. I tried recalling the button in the
ItemCommand and the CommandArgument is blank.
In the past I've gotten around this issue by creating a user control and
placing that in the template column. I can then assign a CommandArgument to
the ImageButton in the User Control and everything works fine.
Please Help!
-Austin Bailey
(e-mail address removed)
(please remove ".nospam" when replying)
in. I am assigning the CommandArgument in the ItemCreated Event on the
DataGrid but when I try clicking on the ImageButton and the ItemCommand
event fires the Command Argument is gone. I've even tried assigning the
ToolTip text on the ImageButton to be sure that the properties are being
assigned and the ToolTip does appear in the browser window. I've made sure
that the DataGrid isn't rebinding before the ItemCommand Event too.
I've tried getting the ImageButton reference in the DataGrid with:
ImageButton btnAdd = (ImageButton)e.Item.Controls[0].Controls[9];
and
ImageButton btnAdd = (ImageButton)e.Item.Cells[1].Controls[9];
and
ImageButton btnAdd = (ImageButton)e.Item.FindControl("btnAdd");
they all return the correct control to me.
I then assign the CommandArgument with:
btnAdd.CommandArgument = "48";
I can see in the Watch window that the command argument is there. I then
click the image button on the web page. I tried recalling the button in the
ItemCommand and the CommandArgument is blank.
In the past I've gotten around this issue by creating a user control and
placing that in the template column. I can then assign a CommandArgument to
the ImageButton in the User Control and everything works fine.
Please Help!
-Austin Bailey
(e-mail address removed)
(please remove ".nospam" when replying)