GridView Properties for header in a column

Posted by Anishabathija under ASP.NET on 4/1/2014 | Points: 10 | Views : 446 | Status : [Member] | Replies : 2
hey
I have a datagrid "Datagrid1" ,and my first column variable value is "FirstName" and I want to display it's header as "Name" which is my first column. kindly advise.




Responses

Posted by: Allemahesh on: 4/1/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
Try the below one:-

Datagrid1.Columns[0].HeaderText = "Name";

Happy coding.

Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A2H on: 4/1/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,
You can use the HeaderText property of DataGrid to customize the header text in a column of DataGrid.
Sample Code
<asp:DataGrid ID="Grid" runat="server" PageSize="5" AllowPaging="True" DataKeyField="FirstName"
AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:BoundColumn HeaderText="Name" DataField="FirstName"></asp:BoundColumn>
<%--Your other columns here--%>
</Columns>
</asp:DataGrid>


Thanks,
A2H
My Blog

Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response