J
JSanford9482
Hi All,
I have a Repeater that contains a LinkButton as one of the items in the
ItemTemplate. I have the OnCommand (method is called "messageActions")
and CommandName ("view") properties set, as well as a CommandArgument
for the LinkButton to fire off when clicked. For some reason, when I
try to set the CommandEventHandler for the LinkButton:
this.messageSubject.Command += new CommandEventHandler(messageActions);
I get an object reference runtime error. I have the LinkButton
delcared.
Can someone give me an example on the correct way to set this up so my
method will fire? My code snippet is below. Thanks so much in advance!
<asp:Repeater ID="messageRepeater" Runat="server">
<ItemTemplate>
<asp:LinkButton ID="messageSubject" OnCommand="messageActions"
CommandName="view" CommandArgument='<%#
DataBinder.Eval(Container.DataItem,"Id") %>' Runat="server"><%#
DataBinder.Eval(Container.DataItem,"MessageSubject")
%></asp:LinkButton>
</ItemTemplate>
protected void messageActions(Object sender, CommandEventArgs e)
{
string command = e.CommandName;
switch (command)
{
(do something)
}
}
I have a Repeater that contains a LinkButton as one of the items in the
ItemTemplate. I have the OnCommand (method is called "messageActions")
and CommandName ("view") properties set, as well as a CommandArgument
for the LinkButton to fire off when clicked. For some reason, when I
try to set the CommandEventHandler for the LinkButton:
this.messageSubject.Command += new CommandEventHandler(messageActions);
I get an object reference runtime error. I have the LinkButton
delcared.
Can someone give me an example on the correct way to set this up so my
method will fire? My code snippet is below. Thanks so much in advance!
<asp:Repeater ID="messageRepeater" Runat="server">
<ItemTemplate>
<asp:LinkButton ID="messageSubject" OnCommand="messageActions"
CommandName="view" CommandArgument='<%#
DataBinder.Eval(Container.DataItem,"Id") %>' Runat="server"><%#
DataBinder.Eval(Container.DataItem,"MessageSubject")
%></asp:LinkButton>
</ItemTemplate>
protected void messageActions(Object sender, CommandEventArgs e)
{
string command = e.CommandName;
switch (command)
{
(do something)
}
}