Update of /cvsroot/springnet/Spring.Net/examples/Spring/Spring.WebQuickStart/src/Spring.WebQuickStart.2005/DataBinding/EasyEmployeeInfo
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv5057/DataBinding/EasyEmployeeInfo
Modified Files:
Default.aspx Default.aspx.cs
Log Message:
fixed SPRNET-819, SPRNET-820
Index: Default.aspx.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/examples/Spring/Spring.WebQuickStart/src/Spring.WebQuickStart.2005/DataBinding/EasyEmployeeInfo/Default.aspx.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Default.aspx.cs 3 Dec 2007 16:11:31 -0000 1.1
--- Default.aspx.cs 14 Dec 2007 16:38:17 -0000 1.2
***************
*** 1,4 ****
--- 1,5 ----
using System;
using System.Diagnostics;
+ using System.Web.UI.WebControls;
/// <summary>
***************
*** 15,21 ****
}
! protected void Page_Load(object sender, EventArgs e)
! {}
protected void btnSave_Click(object sender, EventArgs e)
--- 16,48 ----
}
! protected override void OnInitializeControls(EventArgs e)
! {
! base.OnInitializeControls(e);
+ InitializeHobbiesList();
+ }
+
+ private void InitializeHobbiesList()
+ {
+ // fill lstHobbies with 'Hobby' items
+ Hobby[] hobbies = {
+ new Hobby("1", "Tennis"),
+ new Hobby("2", "Climbing"),
+ new Hobby("3", "Sailing"),
+ new Hobby("4", "Reading")
+ };
+
+ this.lstHobbies.SelectionMode = ListSelectionMode.Multiple;
+
+ // assign the list in any case - this is required for DataSourceItemFormatter to be able
+ // to access Hobby objects
+ this.lstHobbies.DataSource = hobbies;
+ this.lstHobbies.DataTextField = "Title";
+ this.lstHobbies.DataValueField = "UniqueKey";
+ if (!IsPostBack)
+ {
+ this.lstHobbies.DataBind();
+ }
+ }
protected void btnSave_Click(object sender, EventArgs e)
***************
*** 23,27 ****
// do something with employee such as:
// employeeDao.Save(Employee);
!
Debug.Write(Employee);
}
--- 50,54 ----
// do something with employee such as:
// employeeDao.Save(Employee);
!
Debug.Write(Employee);
}
Index: Default.aspx
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/examples/Spring/Spring.WebQuickStart/src/Spring.WebQuickStart.2005/DataBinding/EasyEmployeeInfo/Default.aspx,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Default.aspx 3 Dec 2007 16:11:31 -0000 1.1
--- Default.aspx 14 Dec 2007 16:38:17 -0000 1.2
***************
*** 102,105 ****
--- 102,120 ----
</tr>
<tr>
+ <td>Hobbies:</td>
+ <td><asp:ListBox id="lstHobbies" runat="server" SelectionMode="Multiple" BindingTarget="Employee.Hobbies" /></td>
+ </tr>
+ <tr>
+ <td>Favorite Food:</td>
+ <td>
+ <spring:CheckBoxList id="lstFavoriteFood" runat="server" BindingTarget="Employee.FavoriteFood">
+ <asp:ListItem value="0">Cheese</asp:ListItem>
+ <asp:ListItem value="1">Noodles</asp:ListItem>
+ <asp:ListItem value="2">Fruits</asp:ListItem>
+ <asp:ListItem value="3">Vegetables</asp:ListItem>
+ </spring:CheckBoxList>
+ </td>
+ </tr>
+ <tr>
<td> </td>
<td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
|