[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


"Open in New Tab" doesn't work for my GridView/DataView controls

Posted on 2009-05-12
Medium Priority
Last Modified: 2012-05-06
When I right-click a CommandField link in a GridView/DataView control on my ASP.NET page the "Open in New Tab" doesn't work. I stay in the same browser window.
Question by:GordJones
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 13

Expert Comment

ID: 24371224
Hi! Create an item template for your gridview and add an Hyperlink control. Something like...
.aspx page
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            <asp:TemplateField HeaderText="Link">
                    <asp:HyperLink ID="HyperLink1" runat="server" />
.cs file
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        if (e.Row.RowType == DataControlRowType.DataRow)
            HyperLink hl = (HyperLink) e.Row.FindControl("HyperLink1");
            hl.Text = e.Row.Cells[0].Text; //you can set your hyperlink text here
            hl.NavigateUrl = "http://www.yahoo.com"; //destination page when hyperlink is clicked

Open in new window


Author Comment

ID: 24375697
I guess I was looking for a reason/explaination as to why the default CommandField link option doesn't operate as expected and how to make it act as expected.
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24433336
from what I know, the "open in new tab" behaviour cannot be controlled from the server, only in the client's browser settings...
please double-check those settings.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 24433904
My Internet Expoler settings are set for Tabbed Browsing and to open new links in new tabs. Tried some other settings, no different. Any other ideas out there?

Author Comment

ID: 24434413
My code in the gridview is:
    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Response.Redirect("DETAIL.ASPX?AssetID=" & GridView1.SelectedValue.ToString)
    End Sub

Open in new window

LVL 60

Expert Comment

ID: 24454389
can you please submit the related html code from the browser here or give us a working URL, so we can check the page and give you some suggestions... can you use "open in a new tab" for other pages?

Author Comment

ID: 24454896
Yes I can "Open in a new tab" for links that are not in the Gridview.
The page is on an Intranet.
The code I posted previously was from the aspx.vb. I will post the gridview code from the aspx file (the link is the first column "Details")

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" 
        PageSize="15" Width="100%" DataKeyNames="ASSETID" EmptyDataText="No records found!">
            <asp:CommandField SelectText="Details" ShowSelectButton="True" />
            <asp:BoundField DataField="ASSETID" HeaderText="ASSETID" 
                SortExpression="ASSETID" InsertVisible="False" ReadOnly="True" 
                Visible="False" />
            <asp:BoundField DataField="ISCHILD" HeaderText="IS CHILD" 
                SortExpression="IsChild" ReadOnly="True" InsertVisible="False" >
            <ItemStyle HorizontalAlign="Center" />
            <asp:BoundField DataField="DESCRIPTION" HeaderText="DESCRIPTION" 
                SortExpression="DESCRIPTION" />
            <asp:BoundField DataField="IDENTIFICATIONNO" HeaderText="V.I.N." 
                SortExpression="IDENTIFICATIONNO" />
            <asp:BoundField DataField="LOCATION" HeaderText="LOCATION" 
                SortExpression="LOCATION" />
            <asp:BoundField DataField="INVOICENO" HeaderText="INVOICE #" 
                SortExpression="INVOICENO" />
            <asp:BoundField DataField="VENDORNAME" HeaderText="VENDOR NAME" 
                SortExpression="VENDORNAME" />
            <asp:BoundField DataField="EQUIPNO" HeaderText="EQUIP #" 
                SortExpression="EQUIPNO" />
            <asp:BoundField DataField="MODELNO" HeaderText="MODEL #" 
                SortExpression="MODELNO" />

Open in new window

LVL 60

Accepted Solution

HainKurt earned 1500 total points
ID: 24468640
probably you cannot use "Right Click - Open in New tab" feature, since it is not a link, but a command (think it as a button, you cannot right click on a button and open in new tab).
But If you really need to open in a new window, you may use target property (set it to "_blank")

Author Closing Comment

ID: 31580674
This was the answer I was looking for "Can not use it because it is a button, not a link".

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question