<asp:GridView ID="gvCorrespondence" runat="server" DataKeyNames="[MY ID(s)]" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<td width="11%" class="topnavAddressBorder">
<asp:ImageButton ID="ibtnAdd" runat="server" CommandName="Add" ImageUrl="~\images\btnAdd.gif"/>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<td>
<asp:ImageButton ID="ibtnEdit" runat="server" CommandName="Edit" CommandArgument='<%#DataBinder.Eval(Container.Data Item, "[MY ID(s)]") %>' ImageUrl="~\images\btnEdit.gif"/>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Then in the OnItemCommand sub:
Protected Sub OnItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs ) Handles gvCorrespondence.RowCommand
Dim id As Decimal = -1
Try
id = cDec((e.CommandArgument))
Select Case e.CommandName
Case "Add"
Response.Redirect([DETAILS PAGE] & "ID=-1")
Case "Edit"
Response.Redirect([NAVIGATE_TO] & "ID=" & id.ToString())
End Select
Catch ex As Exception
Throw ex
End Try
End Sub
|