?
Solved

Change HeaderText of DataGrid

Posted on 2004-10-01
1
Medium Priority
?
1,233 Views
Last Modified: 2009-12-16
I want to change HeaderText of Datagrid. This is my solution
Here my code:
<asp:BoundColumn DataField="ProductID" SortExpression="ProductID" HeaderText="Product ID"></asp:BoundColumn>
<asp:BoundColumn DataField="ProductName" SortExpression="ProductName" HeaderText="<%# GetText() %>"></asp:BoundColumn>
<asp:BoundColumn DataField="QuantityPerUnit" SortExpression="QuantityPerUnit" HeaderText="Quantity Per Unit"></asp:BoundColumn>
----
private string GetText()
{
     return "Hello";
}

But I get Error:

CS0117: 'System.Web.UI.WebControls.BoundColumn' does not contain a definition for 'DataBinding'

Note: I don't want to use:
MyDataGrid.Columns[2].HeaderText="Hello";      

Thanks!
0
Comment
Question by:minhngvan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
123654789987 earned 375 total points
ID: 12215438
Since it a bound column u have to specify the DataField property of the Column.  If u are populating the Column from a DataTable then DataField is one of the columns of this dataTable. Howeveru can have a Column Header Text of your choice by using the HeaderText property.

See the following link on BoundColumns.

http://aspnet.4guysfromrolla.com/articles/072603-1.aspx
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question