views:

58

answers:

1

Ok, this should be really easy, but I just don't have enough experience.

I need to throw a GridView on a WebForm and populate with a List, where Template is my class that has ID, Name, CreatedOn, etc... properties.

The GridView needs to display each Template Name as a link. The link should point to TemplateEdit.aspx page, with the following URL: TemplateEdit.aspx?ID={ID of Template}.

I also need a Delete link (preferably an image link), that should popup a Yes/No delete confirmation dialog.

I've actually done this before in 2005 or so, but I simply can't remember anymore.

+2  A: 

Here's how you do it (borrowed the code from here to save some typing)

<asp:TemplateField HeaderText="Statement" SortExpression="Statement">
  <ItemTemplate>
    <asp:HyperLink ID="Link1" runat="server" NavigateUrl='<%# Bind("ID", "~/TemplateEdit.aspx?ID={0}") %>' Text="The Best Link"></asp:HyperLink  >
  </ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
  <ItemTemplate>
    <asp:ImageButton ID="DeleteButton" Runat="server" ImageUrl="~/images/delete.gif" OnClientClick="return confirm('Are you sure you want to delete this?');" ToolTip="Delete" CommandName="Delete" />
    </ItemTemplate>
</asp:TemplateField>

didn't actually test it, but looks like it should work.

roman m