Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7974927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:30:59+00:00 2026-06-04T08:30:59+00:00

I have a GridView Template field containing an ASP:Label field which has a unique

  • 0

I have a GridView Template field containing an ASP:Label field which has a unique reference number per Row. I also have an open Javascript function assigned to that control which opens a URL in a new window and displays the document of the same reference number.

I don;t know how to obtain the reference number when the user clicks the LinkButton on a particular row, and pass it to my Javascript function before the window opens.

Code:

enter code here

function openPreview() 
{
     var url = "quotereport.aspx?view=esq&&ref=REFNUMBER"; window.open(url);
}

<asp:TemplateField HeaderText="" ShowHeader="False">
    <ItemTemplate>
    <asp:LinkButton ID="lbNewWindow" runat="server" OnClientClick="openPreview    ()">Window</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:31:00+00:00Added an answer on June 4, 2026 at 8:31 am

    You will have to add RowDataBound event to the grid. In RowDataBound event every row that is created is accessible with data. Bind javascript to link button instead of html as you did and pass Reference number to the javascript function from RowDataBound event.

        protected void gvListing_RowDataBound(object sender, GridViewRowEventArgs e)
        {           
            if (e.Row.RowType == DataControlRowType.DataRow)
            {                
              System.Web.UI.WebControls.LinkButton lbNewWindow= new System.Web.UI.WebControls.LinkButton();    
                    lbNewWindow = (System.Web.UI.WebControls.LinkButton)e.Row.FindControl("lbNewWindow");                    
                    if (lbNewWindow!= null)
                    {
                        string YourRefNumber = DataBinder.Eval("e.Row.DataItem", "ColumnNameInDataSource").ToString();
                        lbNewWindow.Attributes.Add("onclick","openPreview('"+ YourRefNumber + "')");
    
                    } 
             }          
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview with a template field that has a HyperLink: <asp:TemplateField ItemStyle-Width=12%
I have a GridView which has following template field that holds the filename, when
I have a gridview that has a template field containing a checkbox as one
In a gridview I have the following Template Field containing a textbox <asp:TemplateField ShowHeader=true
i have this template field inside a gridview. <asp:TemplateField ItemStyle-HorizontalAlign=Center> <ItemTemplate> <asp:ImageButton ID=ImageButton2 ImageUrl=~/images/DeleteRecord.gif
I have a traditional ASP.NET GridView. Inside of it I have a Template Field
I have a template field in a gridview with a label whose text I
I have a gridview which contains a hyper link as a template field ,now
I have a GridView in Which I have four TextBoxes in the Template Field.
I dynamically create gridview, and in this grid I have template field also field.HeaderTemplate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.