This is a migrated thread and some comments may be shown as answers.

[Solved] asp:ImageButton within GridTemplateColumn has CommandArgument value reset

1 Answer 221 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan Bartsch
Top achievements
Rank 1
Ryan Bartsch asked on 24 Feb 2010, 10:50 PM
Greetings,

I have tried following the example:
http://www.telerik.com/help/aspnet/grid/radgrid-telerik.webcontrols.radgrid-itemcreated_ev.html

I'm using an asp:ImageButton within a RadGrid GridTemplateColumn and I set the CommandArgument property of the ImageButton in the code-behind (either during OnLoad or OnItemCreated of the RadGrid). However, in the Click/Command event handlers of the button, the CommandArgument value has been reverted to String.Empty.

I've stepped through the process and the ImageButton.CommandArgument does get set (to a guid) correctly, but alas this value is gone when I need it.

Any ideas would be greatly appreciated.

-Ryan

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Feb 2010, 07:13 AM
Hi,

Could you make sure that you are following the same method to set the CommadArgument .

C#
 protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridDataItem)  
            {  
                GridDataItem dataItem = (GridDataItem)e.Item;  
                ((ImageButton)dataItem["ImageColumn"].FindControl("ImageButton1")).CommandArgument = "MyValue";  
            }  
        }  
 
 protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == "MyImage"
            { 
            } 
        } 


Thanks,
Princy
Tags
Grid
Asked by
Ryan Bartsch
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or