I'm trying to get the backend table attached to the dropdown filter on the default List.aspx page. The following code is running in the OnDataBinding event of the dynamic control. I'm getting a null value. What am I doing wrong?
QueryableFilterUserControl fuc = (sender as DynamicFilter).FilterTemplate as QueryableFilterUserControl;
if (fuc.FilterControl is DropDownList)
{
DropDownList list = fuc.FilterControl as DropDownList;
list.Items.Add(new ListItem("XXX"));//works fine
MetaTable x = fuc.FindMetaTable();
if (x != null)
{
list.Items.Add(new ListItem(x.Name));//does not work
}
}
Well basically trying to filter out the dropdown list values based on some conditions. To do that I need to know, dynamically, what table is the dropdownlist expressing. Then clear the items of that list generated by framework, and adding customized values
to that list. I found a workaround, although not very elegant. On the pre_render of the associated label of the dropdown, I check the name of the label, which gives me the table name associated with the dropdown list :p
greatbear
Member
160 Points
189 Posts
QueryableFilterUserControl MetaTable null
Feb 03, 2012 01:55 PM|LINK
I'm trying to get the backend table attached to the dropdown filter on the default List.aspx page. The following code is running in the OnDataBinding event of the dynamic control. I'm getting a null value. What am I doing wrong?
QueryableFilterUserControl fuc = (sender as DynamicFilter).FilterTemplate as QueryableFilterUserControl; if (fuc.FilterControl is DropDownList) { DropDownList list = fuc.FilterControl as DropDownList; list.Items.Add(new ListItem("XXX"));//works fine MetaTable x = fuc.FindMetaTable(); if (x != null) { list.Items.Add(new ListItem(x.Name));//does not work } }sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: QueryableFilterUserControl MetaTable null
Feb 03, 2012 03:16 PM|LINK
Sorry Greatbear, not really sure what you are trying to achive?
Always seeking an elegant solution.
greatbear
Member
160 Points
189 Posts
Re: QueryableFilterUserControl MetaTable null
Feb 03, 2012 04:55 PM|LINK
Well basically trying to filter out the dropdown list values based on some conditions. To do that I need to know, dynamically, what table is the dropdownlist expressing. Then clear the items of that list generated by framework, and adding customized values to that list. I found a workaround, although not very elegant. On the pre_render of the associated label of the dropdown, I check the name of the label, which gives me the table name associated with the dropdown list :p
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: QueryableFilterUserControl MetaTable null
Feb 04, 2012 01:25 PM|LINK
you can get the table name simply by accessing the Column and the parent table
hope that helps
Always seeking an elegant solution.