J
Jonathan Wood
Greetings,
I have a GridView control. For a couple of reasons, I ended up with a
TemplateField to contain my Edit and Delete links, something like this:
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server"
CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
CausesValidation="False"
CommandName="Edit" Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="lnkDelete" runat="server"
CausesValidation="false"
CommandName="Delete" Text="Delete"
OnClientClick="return confirm('Are you sure you want to delete this
record?');" />
</ItemTemplate>
In addition, the GridView control is bound to an ObjectDataSource object
that contains the following:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteActivity" InsertMethod="InsertActivity"
SelectMethod="GetActivities" TypeName="SoftCircuits.MediCorp.Activities"
UpdateMethod="UpdateActivity">
<DeleteParameters>
<asparameter Name="activityId" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
...
</UpdateParameters>
<SelectParameters>
...
</SelectParameters>
<InsertParameters>
...
</InsertParameters>
</asp:ObjectDataSource>
I'm trying to understand how some of this information hooks up. When I click
the delete link (and click OK in the confirmation), the DeleteActivity
method of SoftCircuits.MediCorp.Activities does in fact get called. However,
the activityId argument is always 0.
Can anyone help me understand where the ObjectDataSource should be getting
this argument value from such that it would represent the id of the record
on the row for which the Delete link was clicked?
The activityId represents the primary key of the table being displayed.
Thanks.
I have a GridView control. For a couple of reasons, I ended up with a
TemplateField to contain my Edit and Delete links, something like this:
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server"
CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
CausesValidation="False"
CommandName="Edit" Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="lnkDelete" runat="server"
CausesValidation="false"
CommandName="Delete" Text="Delete"
OnClientClick="return confirm('Are you sure you want to delete this
record?');" />
</ItemTemplate>
In addition, the GridView control is bound to an ObjectDataSource object
that contains the following:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteActivity" InsertMethod="InsertActivity"
SelectMethod="GetActivities" TypeName="SoftCircuits.MediCorp.Activities"
UpdateMethod="UpdateActivity">
<DeleteParameters>
<asparameter Name="activityId" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
...
</UpdateParameters>
<SelectParameters>
...
</SelectParameters>
<InsertParameters>
...
</InsertParameters>
</asp:ObjectDataSource>
I'm trying to understand how some of this information hooks up. When I click
the delete link (and click OK in the confirmation), the DeleteActivity
method of SoftCircuits.MediCorp.Activities does in fact get called. However,
the activityId argument is always 0.
Can anyone help me understand where the ObjectDataSource should be getting
this argument value from such that it would represent the id of the record
on the row for which the Delete link was clicked?
The activityId represents the primary key of the table being displayed.
Thanks.