Answered by:
How to change the display name of a field through programing

Question
-
User745141034 posted
How to change the display name of a field in run-time,please?
I hope change the display name of a field through programing,how to do,please?
Wednesday, November 12, 2008 8:46 PM
Answers
-
User-330204900 posted
Hi Zzdfc, have a look at this article: Dynamic Data – Custom Metadata Providers
Hope this helps [:D]
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, November 13, 2008 3:59 AM
All replies
-
User27657075 posted
By field, do you mean a Label control?
You can do Label1.Text = "Hello World!";
Wednesday, November 12, 2008 10:37 PM -
User-330204900 posted
Hi Zzdfc, have a look at this article: Dynamic Data – Custom Metadata Providers
Hope this helps [:D]
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, November 13, 2008 3:59 AM -
User745141034 posted
I hope like this : MetadataColumn.DisplayName="HeadText"
Can I? How to do?
Thursday, November 13, 2008 10:37 PM -
User-330204900 posted
I hope like this : MetadataColumn.DisplayName="HeadText"
Can I? How to do?
Hi Zzdfc, in V1 of DynamicData the metadata is read only so after the initial load in the Global.asax you can't change it [:(]
However you could write you own Filed Generator based on IAutoFieldGenerator as in this example here:
public class ColumnNameFieldsManager : IAutoFieldGenerator { protected MetaTable _table; public ColumnNameFieldsManager(MetaTable table) { _table = table; } public ICollection GenerateFields(Control control) { List<DYNAMICFIELD> oFields = new List<DYNAMICFIELD>(); foreach (MetaColumn column in _table.Columns) { // carry on the loop at the next column // if scaffold table is set to false or DenyRead if (!column.Scaffold) continue; DynamicField f = new DynamicField(); f.DataField = column.Name; // do your column name look up here f.HeaderText = "***" + column.Name + "***"; oFields.Add(f); } return oFields; } }
And here it is used on the Edit page:
protected void Page_Init(object sender, EventArgs e) { DynamicDataManager1.RegisterControl(DetailsView1); // add ColumnNameFieldsManager to set column names table = DetailsDataSource.GetTable(); DetailsView1.RowsGenerator = new ColumnNameFieldsManager(table); }
Hope this helps [:D]
Friday, November 14, 2008 3:49 AM