Sure. Just use a Template column. This sample has 2 buttons in it - Edit and
Delete.
Note the Delete is wrappen in a Span tag which pops up a Confirm dialog
prior to posting to the server.
If the user clicks No then the dialog closes and no postback occurs. If they
click Yes then the postback occurs.
<asp:TemplateColumn HeaderText="Edit and Delete Buttons">
<ItemTemplate>
<asp:imagebutton CommandName="btnEdit" id="btnEdit" runat="server"
ImageUrl="~/img/edit.gif" ToolTip="Edit"></asp:imagebutton>
<span onclick="return confirm('Do you really want to delete this
record from the system?')">
<asp:imagebutton CommandName="btnDelete" id="btnDelete"
runat="server" ImageUrl="~/img/delete.gif"
ToolTip="Delete"></asp:imagebutton>
</span>
</ItemTemplate>
</asp:TemplateColumn>
There is no source code error.
This is a copy of code from a fully functioning datagrid.
Ensure you copy all of the code including the <asp:TemplateColumn ...> tag
and place it in your datagrid. Change the name of the image and img folder
to your versions.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.