+2005-09-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * DataList.cs: fill in the data keys from BaseDataList so that the
+ events can see them. Only assign DataItem when using data binding and
+ nullify it after all events are raised.
+
2005-09-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* DataList.cs: OnItemCommand() is raised any time OnBubbleEvent is
void DoItem (int i, ListItemType t, object d, bool databind)
{
DataListItem itm = CreateItem (i, t);
- itm.DataItem = d;
+ if (databind)
+ itm.DataItem = d;
DataListItemEventArgs e = new DataListItemEventArgs (itm);
InitializeItem (itm);
Controls.Add (itm);
if (i != -1)
ItemList.Add (itm);
+
OnItemCreated (e);
if (databind) {
itm.DataBind ();
OnItemDataBound (e);
+ itm.DataItem = null;
}
}
Controls.Clear();
IEnumerable ds = null;
+ ArrayList keys = null;
if (useDataSource) {
idx = 0;
ds = DataSourceResolver.ResolveDataSource (DataSource, DataMember);
+ keys = DataKeysArray;
+ keys.Clear ();
} else {
idx = (int) ViewState ["Items"];
}
// items
if (ds != null) {
+ string key = DataKeyField;
foreach (object o in ds) {
+ if (useDataSource && key != "")
+ keys.Add (DataBinder.GetPropertyValue (o, key));
DoItemInLoop (idx, o, useDataSource);
idx++;
}