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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:43:17+00:00 2026-05-30T06:43:17+00:00

I have this scenario. An ascx contains this GridView: <asp:GridView ID=dataTable runat=server > <Columns>

  • 0

I have this scenario.

An ascx contains this GridView:

<asp:GridView ID="dataTable" runat="server" >
    <Columns>
        <asp:TemplateField HeaderText="Key">
            <ItemTemplate>
                <%# ((KeyValuePair<string, string>)(Container.DataItem)).Key%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Value">
            <ItemTemplate>
                <%# ((KeyValuePair<string, string>)(Container.DataItem)).Value%>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

I’m loading a fake Array into the GridView during the Page_Load

var values = new Dictionary<string, string>();
values.Add("test1", "2");
values.Add("test2", "2");

dataTable.DataSource = values;
dataTable.DataBind();

If during the OnPreRender I try to check the value of

dataTable.Rows[0].Cells[0].Text

It has no value. Then the grid is rendered perfectly and every value is in place.
Is there any way to fix this?

  • 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-30T06:43:19+00:00Added an answer on May 30, 2026 at 6:43 am

    You can put a label control like this:

        <asp:TemplateField HeaderText="Key"> 
            <ItemTemplate>
                <asp:Label runat="server" Text="<%# ((KeyValuePair<string, string>)(Container.DataItem)).Key%>"></asp:Label>
            </ItemTemplate> 
        </asp:TemplateField>
    

    And then access the value like this on the user control´s PreRender:

        protected void Page_PreRender(object sender, EventArgs e)
        {
            Label lbl = dataTable.Rows[0].Cells[0].Controls[1] as Label;
            string t = lbl.Text;
        }
    

    Or like this on the consumer page´s PreRender:

        protected void Page_PreRender(object sender, EventArgs e)
        {
            GridView dataTable = dataTableWebUserControl1.FindControl("dataTable") as GridView;
            Label lbl = dataTable.Rows[0].Cells[0].Controls[1] as Label;
            string t = lbl.Text;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we have this scenario: A server which contains needed data and client component which
Good afternoon to all, I have this scenario: I am using SQL Server 'BulkInsert'
I have this scenario. I need to show 3 list boxes on a ASP.NET
The Scenario I have an ASP.Net Web Project that uses a master page. This
I there I have this scenario: a) Notebook :Windows Server 2008 R1, Visual basic
I have this scenario i have a staging table that contains all the record
I have this scenario where I need data integrity in the physical database. For
I have this typical scenario. I have a smartclient application built on .net 2.0
Imagine this scenario: You have a desktop and a laptop. The desktop has a
Consider this scenario. I have my own website, that I use as my identifier,

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.