Get table description from VisibleTables on Default.apsx page.
Feb 07, 2012 01:00 AM|konstantin.konstantinov|LINK
Hello.
I have ASP.NET 4 Dynamic Data Site.
I would like to set a tooltip property with table description in a HyperLink control on Default.apsx page.
I have used MetaTableExtensions class:
public static string GetDescription(this MetaTable table)
{
return ((DescriptionAttribute)table.Attributes[typeof(DescriptionAttribute)]).Description;
}
On Default.aspx page there is only MetaModel.Default.VisibleTables that is binded to GridView. For example, on List.apsx page i am be able to get description by code MyNamespace.Classes.MetaTableExtensions.GetDescription(table).
What do you think, how can i get my description on the Default.aspx page?
Re: Get table description from VisibleTables on Default.apsx page.
Feb 07, 2012 11:43 PM|konstantin.konstantinov|LINK
Thank you very much!
I have just changed a bit of my code and voila!
Sorry for Russian.
// Вывод в меню основных таблиц, не скрытых по умолчанию
private void GetMainTable()
{
var tablesInDefaultPage = (from
Tables in MetaModel.Default.VisibleTables.ToList()
where
(!Tables.Attributes.OfType<HideTableInDefaultAttribute>().DefaultIfEmpty(HideTableInDefaultAttribute.Default).First().Hide
& !Tables.DisplayName.StartsWith("Справочник", StringComparison.OrdinalIgnoreCase)
& !Tables.DisplayName.StartsWith("Реестр", StringComparison.OrdinalIgnoreCase))
orderby Tables.DisplayName
select new
{
DisplayName = Tables.DisplayName,
ListActionPath = Tables.ListActionPath,
Description = iSite.Classes.MetaTableExtensions.GetDescription(Tables)
}).ToList();
if (tablesInDefaultPage.Count == 0)
{
throw new InvalidOperationException("Нет ни одной доступной таблицы. Убедитесь, что по крайней мере одна модель данных зарегистрирована в Global.asax, технология scaffolding включена или реализованы настраиваемые страницы.");
}
this.tblMenuMainTables.DataSource = tablesInDefaultPage;
this.tblMenuMainTables.DataBind();
}
Hi konstantin.konstantinov, no problem with the Russin (other than I don't read Russian
or speak it I only just manage English my only language) I'm glad you are working.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Member
1 Points
24 Posts
Get table description from VisibleTables on Default.apsx page.
Feb 07, 2012 01:00 AM|konstantin.konstantinov|LINK
Hello.
I have ASP.NET 4 Dynamic Data Site.
I would like to set a tooltip property with table description in a HyperLink control on Default.apsx page.
I have used MetaTableExtensions class:
On Default.aspx page there is only MetaModel.Default.VisibleTables that is binded to GridView. For example, on List.apsx page i am be able to get description by code MyNamespace.Classes.MetaTableExtensions.GetDescription(table).
What do you think, how can i get my description on the Default.aspx page?
Thank you.
All-Star
17915 Points
5679 Posts
MVP
Re: Get table description from VisibleTables on Default.apsx page.
Feb 07, 2012 01:26 PM|sjnaughton|LINK
your problem is you cannot get acces tot he table from the page so what I have done is:
then in the code behind
Always seeking an elegant solution.
Member
1 Points
24 Posts
Re: Get table description from VisibleTables on Default.apsx page.
Feb 07, 2012 11:43 PM|konstantin.konstantinov|LINK
Thank you very much!
I have just changed a bit of my code and voila!
Sorry for Russian.
All-Star
17915 Points
5679 Posts
MVP
Re: Get table description from VisibleTables on Default.apsx page.
Feb 08, 2012 05:51 AM|sjnaughton|LINK
Hi konstantin.konstantinov, no problem with the Russin (other than I don't read Russian
or speak it I only just manage English my only language) I'm glad you are working.
Always seeking an elegant solution.