Link to home
Start Free TrialLog in
Avatar of minhngvan
minhngvan

asked on

Change HeaderText of DataGrid

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!
ASKER CERTIFIED SOLUTION
Avatar of 123654789987
123654789987

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial