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

  • Home
  • SEARCH
  • 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 8689307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:36:47+00:00 2026-06-12T23:36:47+00:00

I am new to ASP.NET What I try to do is capture the unique

  • 0

I am new to ASP.NET

What I try to do is capture the unique ID (ProposedID) in the lblProposedID field, and pass it to another page.

Lable in the GridView

<asp:TemplateField HeaderText="ID" 
    SortExpression="ID" ItemStyle-Width="5%">
    <ItemTemplate>
    <asp:Label ID="lblProposedID" runat="server" 
        Text='<%#Eval("ProposedID") %>'>
    </asp:Label>
    </ItemTemplate>
    <FooterTemplate>
    </FooterTemplate>
</asp:TemplateField>

Code Behind

private void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
    String rColor;
    System.Drawing.ColorConverter colConvert = new ColorConverter();

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        int RowNum = e.Row.RowIndex;
        if (RowNum % 2 == 1)
        {
            rColor = "#FFFFFF";
            //e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#DDDDDD'");
        }
        else
        {
            rColor = "#F5F5F5";
            //e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='" ++ "'");
        }

        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(rColor);
        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='" + rColor + "'");
        e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00FFFF'");
        e.Row.Attributes.Add("onclick", "window.open('popup.aspx?ProposedID=" + (Label)  e.Row.FindControl("lblProposedID") + 
        "','cal','width=600,height=300,left=270,top=180')"); 
        //e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
    }
}

This is the line when I couldn’t get it to work.

e.Row.Attributes.Add("onclick", "window.open('popup.aspx?textbox={0}" + (Label)e.Row.FindControl("lblProposedID") + 
"','cal','width=600,height=300,left=270,top=180')"); 

Please help. Thanks in advance.

  • 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-12T23:36:49+00:00Added an answer on June 12, 2026 at 11:36 pm

    Use OnRowDataBound instead. The text was always null in that event but when I changed it to RowDataBound, it picked the ID

    Add RowDataBound event

    <asp:GridView runat="server" ID="GridView1" 
    AutoGenerateColumns="false" OnRowDataBound="GridView1_RowCreated">
    

    CodeBehind

        protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
        {
            String rColor;
    
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int RowNum = e.Row.RowIndex;
                if (RowNum % 2 == 1)
                {
                    rColor = "#FFFFFF";
                    //e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#DDDDDD'");
                }
                else
                {
                    rColor = "#F5F5F5";
                    //e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='" ++ "'");
                }
    
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='" + rColor + "'");
                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00FFFF'");
                e.Row.Attributes.Add("onclick", "window.open('popup.aspx?ProposedID=" + ((Label)e.Row.FindControl("lblProposedID")).Text +
                "','cal','width=600,height=300,left=270,top=180')");
                //e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I create a new page in asp.net and try to include the master
I created a new ASP.NET MVC application. The home page looks like this: I
I am new ASP.NET and I have never used a GridView or DataGrid, but
I'm testing the new ApiController in asp.net mvc 4 beta but when I try
I'm creating a new ASP.net website via Visual Studio. I then try to run
I'm new in ASP.NET. Everytime I try to run my application, I encounter the
I have an ASP.Net application with the following code: try { sql = new
I am a new ASP.NET developer and trying to use a GridView control to
I'm creating a new ASP.net website via Visual Studio. I then try to run
New ASP.NET Web API HttpClient has been giving me some strange results. Here is

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.