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 6870599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:42:11+00:00 2026-05-27T03:42:11+00:00

I am dynamically creating several gridviews depending on data in a DB. I generate

  • 0

I am dynamically creating several gridviews depending on data in a DB.
I generate the gridview as follows in a foreach statement:

GridView gdv = new GridView();
gdv.ID = "gdv" + i.ToString();
gdv.SelectedIndexChanged += new EventHandler(gdv_SelectedIndexChanged);
gdv.RowDataBound += gdv_RowDataBound; 

RowDataBound looks like the following:

protected void gdv_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
   {             
      e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(((GridView)sender), "Select$" + e.Row.RowIndex);
   }
}

This all works as expected, however the ((GridView)sender) returns the following value:

'gdv00'

What i need returned for this link to work is the following:

'ctl00$ctl00$MainContent$Main$gdv0'

Pretty sure this has something to do with the master pages? but not sure how to reference this properly in the rowdatabound event?

  • 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-05-27T03:42:11+00:00Added an answer on May 27, 2026 at 3:42 am

    The ID of ctl00$ctl00$MainContent$Main$gdv is the UniqueID property of the grid control (client ID is separated by _). This is the ID rendered to the browser. I think the problem here is that the control isn’t added to the control tree immediately, which has been a problem for some in the past. Try doing it this way:

    GridView gdv = new GridView();
    gdv.ID = "gdv" + i.ToString();
    panel.Controls.Add(gdv);
    
    //set grid props
    

    HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am dynamically creating an Item template in a Gridview. TemplateColumn BtnTmpField = new
I am creating several image dynamically using the following code: function refresh_gallery(galleryidentifier, albumid) {
I have an ASPX page that is dynamically creating a gridview from a database
I am having a JSP page, where i am dynamically creating a Table data.
After dynamically creating an element with this: $('#btnAddBanner').click(function () { var uid = new
I am dynamically creating a table with data and check boxes in it, my
I am dynamically creating a NotifyIcon using the code below: Dim traysystem As New
I have a several form elements that I am dynamically creating with javascript when
I have a web server that is dynamically creating various reports in several formats
So if I'm dynamically creating textviews in a foreach loop and want to assign

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.