I have a gridview that's defined like so:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="columnid" DataSourceID="SqlDataSource1"
<Columns>
<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" ForeColor="red" runat="server" onclick="LinkButton1_Click"
Text="Click Me!"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
And the codebehind for LinkButton1_click looks like this:
protected void LinkButton1_click(object sender, EventArgs e)
{
string stringQuery = methodToGetQueryString;
Response.Redirect(queryString, true);
}
This works awesomely except when I try to open the link as a new tab or a new window, it gives me a about:blank page. I've looked around quite a bit and it seems the general consensus seems that instead of using a linkbutton, I have to use a hyperlink? I've tried to change the code inside my ItemTemplate to look like the following:
<ItemTemplate>
<asp:HyperLink ID = "HyperLink1" runat="server" Text="click me!" NavigateURL = "~/setTheUrlHere.aspx" />
</ItemTemplate>
The problem with this is for some strange reason, none of my hyperlinks are actually clickable. I hover over them and when I right click I don't get the option to open in a new tab or window. It looks like it's just a dead link. Do I need to set the href or something? I thought that's what the NavigateURL would do? Or is there a easier way to do what I need using a LinkButton?
Thanks!