I have a database table that has a "Active" field. I want my drop downs to only show "Active = true" items.
Also when looking at the list page for the items, I would like the dropdown filter to sort on the "Active" field, alternately showing true or false or all items.
Hi Jason, Just make a copy of the default ForeignKey_Edit field template and replace the PopulateListControl with you own method. Then use UIHint in your metadata to select you own custom field template (note: you will need to make a copy of the ForeignKey
read only field template and name the same)
Dynamic Data 4
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Member
4 Points
30 Posts
DynamicData Dropdown list
Jan 20, 2011 01:25 PM|jasonbrandt42|LINK
Ok, easy question to answer I hope.
I have a database table that has a "Active" field. I want my drop downs to only show "Active = true" items.
Also when looking at the list page for the items, I would like the dropdown filter to sort on the "Active" field, alternately showing true or false or all items.
i am using vs 2010 and c#
Any ideas would be very approciated, thanks!
DynamicData DropDownList c# VS2010 & .Net 4.0
Contributor
2581 Points
1135 Posts
Re: DynamicData Dropdown list
Jan 20, 2011 02:17 PM|Shuvo Aymon|LINK
you can use sqldatasource binded with dropdownlist to populate it.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
DataTextField="location" DataValueField="location" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged1">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:trailsdbConnectionString %>"
SelectCommand="SELECT ColumnName FROM TableName Where Active='true'"></asp:SqlDataSource>
If more posts give you useful answers, Please mark each as "Answer".
Member
4 Points
30 Posts
Re: DynamicData Dropdown list
Jan 20, 2011 05:53 PM|jasonbrandt42|LINK
I was using a DynamicControl
<asp:DynamicControl runat="server" DataField="Office" ID="DynamicControl_Office"
OnInit="DynamicControl_Init"/>
but i just switched to the regular drop down instead, any ideas on how to do that with a dynamiccontrol?
All-Star
17916 Points
5681 Posts
MVP
Re: DynamicData Dropdown list
Jan 20, 2011 07:14 PM|sjnaughton|LINK
Hi Jason, Just make a copy of the default ForeignKey_Edit field template and replace the PopulateListControl with you own method. Then use UIHint in your metadata to select you own custom field template (note: you will need to make a copy of the ForeignKey read only field template and name the same)
Dynamic Data 4
Always seeking an elegant solution.
Member
4 Points
30 Posts
Re: DynamicData Dropdown list
Jan 21, 2011 11:27 AM|jasonbrandt42|LINK
Oh yes, I completely forgot about the copy and custom field option. Ok, thank you!
None
0 Points
22 Posts
Re: DynamicData Dropdown list
Mar 13, 2013 11:40 AM|SonnyTate|LINK
Where in the metadata does this UIHint go?