I am using normal WebForm and displaying Grid View, but in the UI the column names displayed are as it is like in the Database. But I want them to be more readable i.e. employee_target_cases To Target Employee Cases in the UI. I don't want to rename the
columns in the database. Is there any way to display them in more readable format just for the UI.
I am using normal WebForm and displaying Grid View, but in the UI the column names displayed are as it is like in the Database. But I want them to be more readable i.e. employee_target_cases To Target Employee Cases in the UI. I don't want to rename the
columns in the database. Is there any way to display them in more readable format just for the UI.
You have the ability to set the columns headers to whatever test you like using the standard GridView templates. The official GridView documentation covers the details. It's all point and click.
I am using normal WebForm and displaying Grid View, but in the UI the column names displayed are as it is like in the Database.
If this is the case, I guess you may have used
GridView.AutoGenerateColumns Propertyto make the framework automatic Generate these columns, it will use the column name consistent with the database to display.
If you need to modify the displayed column names, you could try these two methods:
Adjust the HeaderText of columns: You need to set AutoGenerateColumns to false, and set columns and its HeaderText one by one.
Add GridView.RowDataBoundevent, and then determine whether it is a HeaderRow in GridView and modify its content.
Something like this:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
foreach (DataControlFieldHeaderCell cell in e.Row.Cells) { if (cell.Text == "Some Unreadable ColumnName") { cell.Text = "new columnName you want to display"; } }
}
}
Hope this can help you.
Best regards,
Xudong Peng
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Member
5 Points
7 Posts
Renaming Column Names in Grid View in User friendly format in UI only.
Apr 07, 2021 04:02 PM|Shreyas09|LINK
I am using normal WebForm and displaying Grid View, but in the UI the column names displayed are as it is like in the Database. But I want them to be more readable i.e. employee_target_cases To Target Employee Cases in the UI. I don't want to rename the columns in the database. Is there any way to display them in more readable format just for the UI.
All-Star
53711 Points
24031 Posts
Re: Renaming Column Names in Grid View in User friendly format in UI only.
Apr 07, 2021 04:11 PM|mgebhard|LINK
You have the ability to set the columns headers to whatever test you like using the standard GridView templates. The official GridView documentation covers the details. It's all point and click.
https://docs.microsoft.com/en-us/aspnet/web-forms/overview/data-access/accessing-the-database-directly-from-an-aspnet-page/inserting-updating-and-deleting-data-with-the-sqldatasource-cs
Contributor
2400 Points
749 Posts
Re: Renaming Column Names in Grid View in User friendly format in UI only.
Apr 08, 2021 06:26 AM|XuDong Peng|LINK
Hi Shreyas09,
If this is the case, I guess you may have used GridView.AutoGenerateColumns Property to make the framework automatic Generate these columns, it will use the column name consistent with the database to display.
If you need to modify the displayed column names, you could try these two methods:
Something like this:
Something like this:
Hope this can help you.
Best regards,
Xudong Peng
Member
5 Points
7 Posts
Re: Renaming Column Names in Grid View in User friendly format in UI only.
Apr 08, 2021 03:55 PM|Shreyas09|LINK
Thanks alot for your detail explanation!