I have been trying to make hyperlinks in my gridview to work, but I can't seem to. The main problem is that simply clicking on the hyperlinks does nothing. Absolutely nothing at all. The reason for my hyperlinks is that when records are displayed in my gridview, the hyperlinks would allow the user to redirect to my Edit page to edit the selected record. My gridview gets data from an ObjectDataSource, which then calls a stored procedure in my database to execute a query string. TxnID is one of the many columns involved in the query string.
code for hyperlink:
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:HyperLink ID="hlEditTxn" NavigateUrl='<% Eval("TxnID", "~/FXTxnEdit.aspx?TxnID={0}") %>'
Text="Edit" runat="server" ></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
code for Edit page:
public partial class FXTxnEdit : System.Web.UI.Page
{
TransactionHandler txnHnd = null;
MainFunctions mf = null;
int TransactionID = 0;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
string id = Request.QueryString["TxnID"] as string;
if (id == null)
{
Response.Redirect("Default.aspx");
}
For some reason, this does not work. I have tried inserting a Label column in my gridview that displays the TxnID, just to make sure if the ObjectDataSource does get the TxnID:
<asp:TemplateField HeaderText="TxnID">
<ItemTemplate>
<asp:Label ID="lblTxnID" runat="server" Text='<%# Eval("TxnID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
It does get the TxnID, and it does display the TxnID in the gridview, which is good.
Any ideas on what could be wrong? or what else needs to be done or could be done to make the hyperlinks work?