I have a GridView with a custom template field with an item Template of a LinkButton.
I *was* populating the postbackURL of the link button in the rowboundevent and this was all working fine! I now need to add some code before I do the navigate (with an opt out if possible if the code errors). I have tried looking at the click and command options of the linkbutton and I am getting in a mess, it either seems to be posting back to itself and ignoring the function I have created or not doing anything at all!
Can someone please help and tell me what I am doing wrong and how I can get at the very least an apperance of a hyperlink in a gridview, which when clicked I can 1) get details of the row in the gridview (i.e values in other columns), run code (a sproc, using these values) and then navigate to another page.
Thanks in advance!!!
protected void Numbers_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
//change link when clicked
LinkButton ib3 = (LinkButton)e.Row.FindControl("lnk_Number");
//This code was working fine, but I need to run code before redirect
//ib3.PostBackUrl = "~/insert_To_Basket.aspx?Value=" + e.Row.Cells[col_Value].Text + "&Type=" + Range_Type;
ib3.Text = e.Row.Cells[col_Phonenumber].Text;
ib3.PostBackUrl = "";
private void LinkButton_Click(System.Object sender, System.EventArgs e)
// Just in here to see if code is firing
i = sender.ToString();