views:

66

answers:

1

Okay so given a LinkButton inside a the ItemTemplate of a Repeater declared like this -

<asp:LinkButton ID="restrictionDelete" runat="server" CssClass="restrictionDelete" Text="Delete..."
                OnCommand="lnkDeleteRestriction_Command" CommandName="Delete" CommandArgument="<%# Container.DataItem %>"></asp:LinkButton>

Now,..the repeater is being bound to a list of Restriction objects so when the lnkDeleteRestriction_Command is fired I'm expecting that I can cast the CommandEventArgs.CommandArgument which is an object to my Restriction type. This doesn't seem to be so,..I just get the fully qualified type name as a string.

Can I receive a typed command argument at all and if not, why is it an object?

Thanks in advance,

+1  A: 

Yes, and it was probably calling ToString to get it to the string, storing the incorrect value.

Brian
Makes you wonder why the EventArgs property is an object though.
Stimul8d
To accomodate other simple types, like int, long, and bool I believe...
Brian
Makes no odds unless you set the property yourself from code, which is pointless! If you bind it declaratively then it WILL be a string.
Stimul8d