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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:15:56+00:00 2026-05-28T02:15:56+00:00

I want to set datatable header column fields to a Label controls Text property

  • 0

I want to set datatable header column fields to a Label controls Text property of a Gridview HeaderTemplate

  • 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-28T02:15:56+00:00Added an answer on May 28, 2026 at 2:15 am

    I’m not sure I understand your question, but if you want to bind from a datasource to Labels within a TemplateField’s HeaderTemplate and ItemTemplate, you can do this:

    <asp:TemplateField HeaderText="YourField">
        <HeaderTemplate>
            <asp:Label runat="server" Text='<%# Eval("header_database_field") %>'/>
        </HeaderTemplate>
        <ItemTemplate>
            <asp:Label runat="server" Text='<%# Eval("content_database_field") %>'/>
        </ItemTemplate>
    </asp:TemplateField>
    

    Where header_database_field and content_database_field are the fields from your database that you wish to bind.

    If you want to assign a DataTable’s column name(s) to one of the TemplateField’s Labels, you could do something like this programmatically during the RowDataBound event, though I’m not sure why you’d want to:

    DataTable datatable = new DataTable(); // your dt
    
    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if(e.Row.RowType == DataControlRowType.DataRow)
        {
            ((Label)e.Row.Cells[0].Controls[1]).Text = datatable.Columns[0].ColumnName;
        }
    }
    

    Reaplce datatable with your DataTable, and modify the indexes to reference your Cell/Label(s)/ColumnNames.

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

Sidebar

Related Questions

I want to set all the fields and labels on a VFP7 report to
I have a DataTable, fully populated, which I want to set to a DatagridView:
I have a dataTable that lists some objects and I want to set a
I have set the readonly property of 2 datatable columns to true. List.Columns[0].ReadOnly =
I want set interfaceOrientation in one UIView as LandscapeLeft and Portrait in other UIView.
i want set the visibility to itemized overlay in map view. if the zoom
I want set Listbox background to transparent but not working Is there any idea?
I want to set something up so that if an Account within my app
I want to set a background image for a div, in a way that
I want to set a breakpoint on the __DoPostBack method, but it's a pain

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.