I've got a LinkButton control in a user control like this (Accordion is from the AJAX Control Toolkit):
<cc1:Accordion runat="server">
<Panes></Panes>
<HeaderTemplate></HeaderTemplate>
<ContentTemplate>
<asp:TextBox Text='<%# Bind("Title") %>' runat="server"></asp:TextBox>
<asp:LinkButton Text="Update" CommandArgument='<%# Container.DataItem %>' CommandName="ItemUpdate" OnCommand="LinkButton_Command" runat="server"></asp:LinkButton>
</ContentTemplate>
</cc1:Accordion>
The accordion is bound in Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
Accordion1.DataSource = GetACollection();
Accordion1.DataBind();
}
But in the command event handler, no matter what I do, the arguments are always strings:
protected void LinkButton_Command(object sender, CommandEventArgs e)
{
// sender is alway a string (the Text of the clicked button)
// e is always a string property of the Container.DataItem object
}
The strings are coming from the right objects (the button and the bound DataItem, respectively), but I need the objects themselves (the DataItem particularly).
What's going on?