diff options
Diffstat (limited to 'DesignPatterns/src/app/DesignPatterns.Adapter/WebDropDownList.cs')
| -rw-r--r-- | DesignPatterns/src/app/DesignPatterns.Adapter/WebDropDownList.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/DesignPatterns/src/app/DesignPatterns.Adapter/WebDropDownList.cs b/DesignPatterns/src/app/DesignPatterns.Adapter/WebDropDownList.cs new file mode 100644 index 0000000..e356a71 --- /dev/null +++ b/DesignPatterns/src/app/DesignPatterns.Adapter/WebDropDownList.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic;
+using System.Web.UI.WebControls;
+
+namespace DesignPatterns.Adapter {
+ public class WebDropDownList : IDropDownListAdapter {
+ public WebDropDownList( DropDownList dropDown ) {
+ _dropDown = dropDown;
+ }
+
+ public void BindTo( IEnumerable< IDropDownListItem > pairs ) {
+ if ( pairs != null ) {
+ foreach ( IDropDownListItem pair in pairs ) {
+ _dropDown.Items.Add( new ListItem( pair.Text, pair.Value ) );
+ }
+ }
+ }
+
+ public IDropDownListItem SelectedItem {
+ get { return new DropDownListItem( _dropDown.SelectedItem.Text, _dropDown.SelectedItem.Value ); }
+ }
+
+ private DropDownList _dropDown;
+ }
+}
\ No newline at end of file |
