// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
-// (C) 2005 Novell, Inc (http://www.novell.com)
+// (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
-
using System;
using System.Collections;
using System.Collections.Specialized;
[DesignerAttribute ("System.Web.UI.Design.WebControls.DetailsViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
[ControlValuePropertyAttribute ("SelectedValue")]
[DefaultEventAttribute ("PageIndexChanging")]
+ [DataKeyProperty ("DataKey")]
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DetailsView: CompositeDataBoundControl, ICallbackEventHandler, ICallbackContainer, IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer
-#if NET_4_0
- , IDataBoundItemControl
-#endif
+ , IDataBoundItemControl, IDataBoundControl, IFieldControl
{
object dataItem;
throw new HttpException (String.Format (unhandledEventExceptionMessage, ID, "ItemUpdating"));
}
-#if NET_4_0
-
DataBoundControlMode IDataBoundItemControl.Mode {
get {
switch (CurrentMode) {
IDataSource IDataBoundControl.DataSourceObject {
get { return base.DataSourceObject; }
}
-#endif
-
+
+ IAutoFieldGenerator IFieldControl.FieldsGenerator {
+ get {
+ throw new NotImplementedException ();
+ }
+
+ set {
+ throw new NotImplementedException ();
+ }
+ }
[WebCategoryAttribute ("Paging")]
[DefaultValueAttribute (false)]
public virtual bool AllowPaging {
get {
object ob = ViewState ["AllowPaging"];
- if (ob != null) return (bool) ob;
+ if (ob != null)
+ return (bool) ob;
return false;
}
set {
public virtual bool AutoGenerateEditButton {
get {
object ob = ViewState ["AutoGenerateEditButton"];
- if (ob != null) return (bool) ob;
+ if (ob != null)
+ return (bool) ob;
return false;
}
set {
public virtual bool AutoGenerateDeleteButton {
get {
object ob = ViewState ["AutoGenerateDeleteButton"];
- if (ob != null) return (bool) ob;
+ if (ob != null)
+ return (bool) ob;
return false;
}
set {
public virtual bool AutoGenerateInsertButton {
get {
object ob = ViewState ["AutoGenerateInsertButton"];
- if (ob != null) return (bool) ob;
+ if (ob != null)
+ return (bool) ob;
return false;
}
set {
public virtual bool AutoGenerateRows {
get {
object ob = ViewState ["AutoGenerateRows"];
- if (ob != null) return (bool) ob;
+ if (ob != null)
+ return (bool) ob;
return true;
}
set {
public virtual string Caption {
get {
object ob = ViewState ["Caption"];
- if (ob != null) return (string) ob;
- return string.Empty;
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["Caption"] = value;
[WebCategoryAttribute ("Accessibility")]
[DefaultValueAttribute (TableCaptionAlign.NotSet)]
- public virtual TableCaptionAlign CaptionAlign
- {
+ public virtual TableCaptionAlign CaptionAlign {
get {
object o = ViewState ["CaptionAlign"];
- if(o != null) return (TableCaptionAlign) o;
+ if(o != null)
+ return (TableCaptionAlign) o;
return TableCaptionAlign.NotSet;
}
set {
[WebCategoryAttribute ("Layout")]
[DefaultValueAttribute (-1)]
- public virtual int CellPadding
- {
+ public virtual int CellPadding {
get {
if (ControlStyleCreated)
return ((TableStyle) ControlStyle).CellPadding;
return -1;
}
- set {
- ((TableStyle) ControlStyle).CellPadding = value;
- }
+ set { ((TableStyle) ControlStyle).CellPadding = value; }
}
[WebCategoryAttribute ("Layout")]
[DefaultValueAttribute (0)]
- public virtual int CellSpacing
- {
+ public virtual int CellSpacing {
get {
if (ControlStyleCreated)
return ((TableStyle) ControlStyle).CellSpacing;
return 0;
}
- set {
- ((TableStyle) ControlStyle).CellSpacing = value;
- }
+ set { ((TableStyle) ControlStyle).CellSpacing = value; }
}
[DefaultValueAttribute (null)]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
[BrowsableAttribute (false)]
public DetailsViewMode CurrentMode {
- get {
- return hasCurrentMode ? currentMode : DefaultMode;
- }
+ get { return hasCurrentMode ? currentMode : DefaultMode; }
+
private set {
hasCurrentMode = true;
currentMode = value;
[DefaultValueAttribute (DetailsViewMode.ReadOnly)]
[WebCategoryAttribute ("Behavior")]
public virtual DetailsViewMode DefaultMode {
- get {
- return defaultMode;
- }
+ get { return defaultMode; }
set {
defaultMode = value;
RequireBinding ();
[WebCategoryAttribute ("Data")]
[TypeConverter (typeof(StringArrayConverter))]
[EditorAttribute ("System.Web.UI.Design.WebControls.DataFieldEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
- public virtual string[] DataKeyNames
- {
+ public virtual string[] DataKeyNames {
get {
if (dataKeyNames == null)
return emptyKeys;
IOrderedDictionary KeyTable {
get {
- if (_keyTable == null) {
+ if (_keyTable == null)
_keyTable = new OrderedDictionary (DataKeyNames.Length);
- }
return _keyTable;
}
}
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public virtual DataKey DataKey {
get {
- if (key == null) {
+ if (key == null)
key = new DataKey (KeyTable);
- }
return key;
}
}
DataKey OldEditValues {
get {
- if (oldEditValues == null) {
+ if (oldEditValues == null)
oldEditValues = new DataKey (new OrderedDictionary ());
- }
return oldEditValues;
}
}
public virtual string EmptyDataText {
get {
object ob = ViewState ["EmptyDataText"];
- if (ob != null) return (string) ob;
- return string.Empty;
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["EmptyDataText"] = value;
public virtual bool EnablePagingCallbacks {
get {
object ob = ViewState ["EnablePagingCallbacks"];
- if (ob != null) return (bool) ob;
+ if (ob != null)
+ return (bool) ob;
return false;
}
set {
public virtual string FooterText {
get {
object ob = ViewState ["FooterText"];
- if (ob != null) return (string) ob;
- return string.Empty;
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["FooterText"] = value;
return ((TableStyle) ControlStyle).GridLines;
return GridLines.Both;
}
- set {
- ((TableStyle) ControlStyle).GridLines = value;
- }
+ set { ((TableStyle) ControlStyle).GridLines = value; }
}
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public virtual string HeaderText {
get {
object ob = ViewState ["HeaderText"];
- if (ob != null) return (string) ob;
- return string.Empty;
+ if (ob != null)
+ return (string) ob;
+ return String.Empty;
}
set {
ViewState ["HeaderText"] = value;
return ((TableStyle) ControlStyle).HorizontalAlign;
return HorizontalAlign.NotSet;
}
- set {
- ((TableStyle) ControlStyle).HorizontalAlign = value;
- }
+ set { ((TableStyle) ControlStyle).HorizontalAlign = value; }
}
[WebCategoryAttribute ("Styles")]
[BrowsableAttribute (false)]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public virtual int PageCount {
- get {
- return pageCount;
- }
- private set {
- pageCount = value;
- }
+ get { return pageCount; }
+ private set { pageCount = value; }
}
[WebCategoryAttribute ("Paging")]
}
[BrowsableAttribute(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public IAutoFieldGenerator RowsGenerator {
get;
set;
int IDataItemContainer.DataItemIndex {
get { return DataItemIndex; }
}
-
+
+ [MonoTODO ("Make use of it in the code")]
+ [DefaultValue (true)]
+ public virtual bool EnableModelValidation {
+ get;
+ set;
+ }
+
public virtual bool IsBindableType (Type type)
{
return type.IsPrimitive || type == typeof (string) || type == typeof (DateTime) || type == typeof (Guid) || type == typeof (Decimal);
if (view.CanRetrieveTotalRowCount) {
arg.RetrieveTotalRowCount = true;
arg.MaximumRows = 1;
- }
- else {
+ } else
arg.MaximumRows = -1;
- }
}
return arg;
}
AutoGeneratedFieldProperties[] CreateAutoFieldProperties (object dataItem)
{
- if (IsBindableType (dataItem.GetType ()))
- {
+ if (IsBindableType (dataItem.GetType ())) {
AutoGeneratedFieldProperties field = new AutoGeneratedFieldProperties ();
((IStateManager) field).TrackViewState ();
field.Name = "Item";
void RequireBinding ()
{
- if (Initialized) {
+ if (Initialized)
RequiresDataBinding = true;
- }
}
protected virtual Table CreateTable ()
return style;
}
- protected override int CreateChildControls (IEnumerable data, bool dataBinding)
+ protected override int CreateChildControls (IEnumerable dataSource, bool dataBinding)
{
- PagedDataSource dataSource = new PagedDataSource ();
- dataSource.DataSource = CurrentMode != DetailsViewMode.Insert ? data : null;
- dataSource.AllowPaging = AllowPaging;
- dataSource.PageSize = 1;
- dataSource.CurrentPageIndex = PageIndex;
+ PagedDataSource pagedDataSource = new PagedDataSource ();
+ pagedDataSource.DataSource = CurrentMode != DetailsViewMode.Insert ? dataSource : null;
+ pagedDataSource.AllowPaging = AllowPaging;
+ pagedDataSource.PageSize = 1;
+ pagedDataSource.CurrentPageIndex = PageIndex;
if (dataBinding && CurrentMode != DetailsViewMode.Insert) {
DataSourceView view = GetData ();
if (view != null && view.CanPage) {
- dataSource.AllowServerPaging = true;
+ pagedDataSource.AllowServerPaging = true;
if (SelectArguments.RetrieveTotalRowCount)
- dataSource.VirtualCount = SelectArguments.TotalRowCount;
+ pagedDataSource.VirtualCount = SelectArguments.TotalRowCount;
}
}
- bool showPager = AllowPaging && (dataSource.PageCount > 1);
+ bool showPager = AllowPaging && (pagedDataSource.PageCount > 1);
Controls.Clear ();
table = CreateTable ();
// Gets the current data item
if (AllowPaging) {
- PageCount = dataSource.DataSourceCount;
- if (PageIndex >= PageCount && PageCount > 0) {
- pageIndex = dataSource.CurrentPageIndex = PageCount - 1;
- }
- if (dataSource.DataSource != null) {
- IEnumerator e = dataSource.GetEnumerator ();
+ PageCount = pagedDataSource.DataSourceCount;
+ if (PageIndex >= PageCount && PageCount > 0)
+ pageIndex = pagedDataSource.CurrentPageIndex = PageCount - 1;
+ if (pagedDataSource.DataSource != null) {
+ IEnumerator e = pagedDataSource.GetEnumerator ();
if (e.MoveNext ())
dataItem = e.Current;
}
- }
- else {
+ } else {
int page = 0;
object lastItem = null;
- if (dataSource.DataSource != null) {
- IEnumerator e = dataSource.GetEnumerator ();
+ if (pagedDataSource.DataSource != null) {
+ IEnumerator e = pagedDataSource.GetEnumerator ();
for (; e.MoveNext (); page++) {
lastItem = e.Current;
if (page == PageIndex)
table.Rows.Add (row);
list.Add (row);
}
- }
- else {
-
+ } else {
// Creates the set of fields to show
ICollection fieldCollection = CreateFieldSet (dataItem, dataBinding && dataItem != null);
if (showPager && PagerSettings.Position == PagerPosition.Top ||
PagerSettings.Position == PagerPosition.TopAndBottom) {
topPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
- InitializePager (topPagerRow, dataSource);
+ InitializePager (topPagerRow, pagedDataSource);
table.Rows.Add (topPagerRow);
}
if (showPager && PagerSettings.Position == PagerPosition.Bottom ||
PagerSettings.Position == PagerPosition.TopAndBottom) {
bottomPagerRow = CreateRow (-1, DataControlRowType.Pager, DataControlRowState.Normal);
- InitializePager (bottomPagerRow, dataSource);
+ InitializePager (bottomPagerRow, pagedDataSource);
table.Rows.Add (bottomPagerRow);
}
}
MarkAsDataBound ();
OnDataBound (EventArgs.Empty);
}
- }
- else
+ } else
base.EnsureDataBound ();
}
DataControlRowState GetRowState (int index)
{
DataControlRowState rstate = (index % 2) == 0 ? DataControlRowState.Normal : DataControlRowState.Alternate;
- if (CurrentMode == DetailsViewMode.Edit) rstate |= DataControlRowState.Edit;
- else if (CurrentMode == DetailsViewMode.Insert) rstate |= DataControlRowState.Insert;
+ if (CurrentMode == DetailsViewMode.Edit)
+ rstate |= DataControlRowState.Edit;
+ else if (CurrentMode == DetailsViewMode.Insert)
+ rstate |= DataControlRowState.Insert;
return rstate;
}
- protected virtual void InitializePager (DetailsViewRow row, PagedDataSource dataSource)
+ protected virtual void InitializePager (DetailsViewRow row, PagedDataSource pagedDataSource)
{
TableCell cell = new TableCell ();
cell.ColumnSpan = 2;
if (pagerTemplate != null)
pagerTemplate.InstantiateIn (cell);
else
- cell.Controls.Add (PagerSettings.CreatePagerControl (dataSource.CurrentPageIndex, dataSource.PageCount));
+ cell.Controls.Add (PagerSettings.CreatePagerControl (pagedDataSource.CurrentPageIndex, pagedDataSource.PageCount));
row.Cells.Add (cell);
}
return dic;
}
- protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, bool includeReadOnlyFields, bool includePrimaryKey)
+ protected virtual void ExtractRowValues (IOrderedDictionary fieldValues, bool includeReadOnlyFields, bool includeKeys)
{
foreach (DetailsViewRow row in Rows) {
- if (row.Cells.Count < 1) continue;
+ if (row.Cells.Count < 1)
+ continue;
DataControlFieldCell c = row.Cells[row.Cells.Count-1] as DataControlFieldCell;
if (c != null)
c.ContainingField.ExtractValuesFromCell (fieldValues, c, row.RowState, includeReadOnlyFields);
}
- if (!includePrimaryKey && DataKeyNames != null)
+ if (!includeKeys && DataKeyNames != null)
foreach (string key in DataKeyNames)
fieldValues.Remove (key);
}
foreach (DetailsViewRow row in table.Rows) {
switch (row.RowType) {
- case DataControlRowType.Header:
- if (headerStyle != null && !headerStyle.IsEmpty)
- row.ControlStyle.CopyFrom (headerStyle);
- break;
- case DataControlRowType.Footer:
- if (footerStyle != null && !footerStyle.IsEmpty)
- row.ControlStyle.CopyFrom (footerStyle);
- break;
- case DataControlRowType.Pager:
- if (pagerStyle != null && !pagerStyle.IsEmpty)
- row.ControlStyle.CopyFrom (pagerStyle);
- break;
- case DataControlRowType.EmptyDataRow:
- if (emptyDataRowStyle != null && !emptyDataRowStyle.IsEmpty)
- row.ControlStyle.CopyFrom (emptyDataRowStyle);
- break;
- case DataControlRowType.DataRow:
- if (rowStyle != null && !rowStyle.IsEmpty)
- row.ControlStyle.CopyFrom (rowStyle);
- if ((row.RowState & DataControlRowState.Alternate) != 0 && alternatingRowStyle != null && !alternatingRowStyle.IsEmpty)
- row.ControlStyle.CopyFrom (alternatingRowStyle);
- break;
- default:
- break;
+ case DataControlRowType.Header:
+ if (headerStyle != null && !headerStyle.IsEmpty)
+ row.ControlStyle.CopyFrom (headerStyle);
+ break;
+ case DataControlRowType.Footer:
+ if (footerStyle != null && !footerStyle.IsEmpty)
+ row.ControlStyle.CopyFrom (footerStyle);
+ break;
+ case DataControlRowType.Pager:
+ if (pagerStyle != null && !pagerStyle.IsEmpty)
+ row.ControlStyle.CopyFrom (pagerStyle);
+ break;
+ case DataControlRowType.EmptyDataRow:
+ if (emptyDataRowStyle != null && !emptyDataRowStyle.IsEmpty)
+ row.ControlStyle.CopyFrom (emptyDataRowStyle);
+ break;
+ case DataControlRowType.DataRow:
+ if (rowStyle != null && !rowStyle.IsEmpty)
+ row.ControlStyle.CopyFrom (rowStyle);
+ if ((row.RowState & DataControlRowState.Alternate) != 0 && alternatingRowStyle != null && !alternatingRowStyle.IsEmpty)
+ row.ControlStyle.CopyFrom (alternatingRowStyle);
+ break;
+ default:
+ break;
}
if (row.ContainingField is CommandField) {
if (commandRowStyle != null && !commandRowStyle.IsEmpty)
row.ControlStyle.CopyFrom (commandRowStyle);
- }
- else {
+ } else {
if ((row.RowState & DataControlRowState.Edit) != 0 && editRowStyle != null && !editRowStyle.IsEmpty)
row.ControlStyle.CopyFrom (editRowStyle);
if ((row.RowState & DataControlRowState.Insert) != 0) {
fcell.ControlStyle.CopyFrom (fieldHeaderStyle);
if (field.HeaderStyleCreated && !field.HeaderStyle.IsEmpty)
fcell.ControlStyle.CopyFrom (field.HeaderStyle);
- }
- else {
- if (field.ControlStyleCreated && !field.ControlStyle.IsEmpty)
+ } else {
+ if (field.ControlStyleCreated && !field.ControlStyle.IsEmpty) {
foreach (Control c in fcell.Controls) {
WebControl wc = c as WebControl;
if (wc != null)
wc.ControlStyle.MergeWith (field.ControlStyle);
}
+ }
+
if (field.ItemStyleCreated && !field.ItemStyle.IsEmpty)
fcell.ControlStyle.CopyFrom (field.ItemStyle);
}
protected internal override void OnInit (EventArgs e)
{
- Page.RegisterRequiresControlState (this);
+ Page page = Page;
+ if (page != null)
+ page.RegisterRequiresControlState (this);
base.OnInit (e);
}
void ProcessEvent (string eventName, string param, bool causesValidation)
{
- switch (eventName)
- {
- case DataControlCommands.PageCommandName:
- int newIndex = -1;
- switch (param) {
+ switch (eventName) {
+ case DataControlCommands.PageCommandName:
+ int newIndex = -1;
+ switch (param) {
+ case DataControlCommands.FirstPageCommandArgument:
+ newIndex = 0;
+ break;
+ case DataControlCommands.LastPageCommandArgument:
+ newIndex = PageCount - 1;
+ break;
+ case DataControlCommands.NextPageCommandArgument:
+ newIndex = PageIndex + 1;
+ break;
+ case DataControlCommands.PreviousPageCommandArgument:
+ newIndex = PageIndex - 1;
+ break;
+ default:
+ int paramIndex = 0;
+ int.TryParse (param, out paramIndex);
+ newIndex = paramIndex - 1;
+ break;
+ }
+ SetPageIndex (newIndex);
+ break;
+
case DataControlCommands.FirstPageCommandArgument:
- newIndex = 0;
+ SetPageIndex (0);
break;
+
case DataControlCommands.LastPageCommandArgument:
- newIndex = PageCount - 1;
+ SetPageIndex (PageCount - 1);
break;
+
case DataControlCommands.NextPageCommandArgument:
- newIndex = PageIndex + 1;
+ if (PageIndex < PageCount - 1)
+ SetPageIndex (PageIndex + 1);
break;
+
case DataControlCommands.PreviousPageCommandArgument:
- newIndex = PageIndex - 1;
- break;
- default:
- int paramIndex = 0;
- int.TryParse (param, out paramIndex);
- newIndex = paramIndex - 1;
+ if (PageIndex > 0)
+ SetPageIndex (PageIndex - 1);
break;
- }
- ShowPage (newIndex);
- break;
-
- case DataControlCommands.FirstPageCommandArgument:
- ShowPage (0);
- break;
-
- case DataControlCommands.LastPageCommandArgument:
- ShowPage (PageCount - 1);
- break;
- case DataControlCommands.NextPageCommandArgument:
- if (PageIndex < PageCount - 1)
- ShowPage (PageIndex + 1);
- break;
-
- case DataControlCommands.PreviousPageCommandArgument:
- if (PageIndex > 0)
- ShowPage (PageIndex - 1);
- break;
-
- case DataControlCommands.EditCommandName:
- ProcessChangeMode (DetailsViewMode.Edit);
- break;
+ case DataControlCommands.EditCommandName:
+ ProcessChangeMode (DetailsViewMode.Edit);
+ break;
- case DataControlCommands.NewCommandName:
- ProcessChangeMode (DetailsViewMode.Insert);
- break;
+ case DataControlCommands.NewCommandName:
+ ProcessChangeMode (DetailsViewMode.Insert);
+ break;
- case DataControlCommands.UpdateCommandName:
- UpdateItem (param, causesValidation);
- break;
+ case DataControlCommands.UpdateCommandName:
+ UpdateItem (param, causesValidation);
+ break;
- case DataControlCommands.CancelCommandName:
- CancelEdit ();
- break;
+ case DataControlCommands.CancelCommandName:
+ CancelEdit ();
+ break;
- case DataControlCommands.DeleteCommandName:
- DeleteItem ();
- break;
+ case DataControlCommands.DeleteCommandName:
+ DeleteItem ();
+ break;
- case DataControlCommands.InsertCommandName:
- InsertItem (causesValidation);
- break;
+ case DataControlCommands.InsertCommandName:
+ InsertItem (causesValidation);
+ break;
}
}
-
- void ShowPage (int newIndex)
+ public
+ void SetPageIndex (int index)
{
- DetailsViewPageEventArgs args = new DetailsViewPageEventArgs (newIndex);
+ DetailsViewPageEventArgs args = new DetailsViewPageEventArgs (index);
OnPageIndexChanging (args);
if (args.Cancel || !IsBoundUsingDataSourceID)
if (causesValidation && Page != null && !Page.IsValid)
return;
- if (CurrentMode != DetailsViewMode.Edit) throw new HttpException ();
+ if (CurrentMode != DetailsViewMode.Edit)
+ throw new HttpException ();
currentEditOldValues = OldEditValues.Values;
if (causesValidation && Page != null && !Page.IsValid)
return;
- if (CurrentMode != DetailsViewMode.Insert) throw new HttpException ();
+ if (CurrentMode != DetailsViewMode.Insert)
+ throw new HttpException ();
currentEditNewValues = GetRowValues (false, true);
DetailsViewInsertEventArgs args = new DetailsViewInsertEventArgs (param, currentEditNewValues);
EndRowEdit (true);
}
- void EndRowEdit (bool switchToDefaultMode) {
+ void EndRowEdit (bool switchToDefaultMode)
+ {
if (switchToDefaultMode)
ChangeMode (DefaultMode);
oldEditValues = new DataKey (new OrderedDictionary ());
RequireBinding ();
}
- protected internal override void LoadControlState (object ob)
+ protected internal override void LoadControlState (object savedState)
{
- if (ob == null) return;
- object[] state = (object[]) ob;
+ if (savedState == null)
+ return;
+ object[] state = (object[]) savedState;
base.LoadControlState (state[0]);
pageIndex = (int) state[1];
pageCount = (int) state[2];
defaultMode,
(key == null ? null : ((IStateManager)key).SaveViewState()),
(oldEditValues == null ? null : ((IStateManager) oldEditValues).SaveViewState ())
- };
+ };
}
protected override void TrackViewState()
{
base.TrackViewState();
- if (columns != null) ((IStateManager)columns).TrackViewState();
- if (pagerSettings != null) ((IStateManager)pagerSettings).TrackViewState();
- if (alternatingRowStyle != null) ((IStateManager)alternatingRowStyle).TrackViewState();
- if (footerStyle != null) ((IStateManager)footerStyle).TrackViewState();
- if (headerStyle != null) ((IStateManager)headerStyle).TrackViewState();
- if (pagerStyle != null) ((IStateManager)pagerStyle).TrackViewState();
- if (rowStyle != null) ((IStateManager)rowStyle).TrackViewState();
- if (editRowStyle != null) ((IStateManager)editRowStyle).TrackViewState();
- if (insertRowStyle != null) ((IStateManager)insertRowStyle).TrackViewState();
- if (emptyDataRowStyle != null) ((IStateManager)emptyDataRowStyle).TrackViewState();
- if (key != null) ((IStateManager)key).TrackViewState();
+ if (columns != null)
+ ((IStateManager)columns).TrackViewState();
+ if (pagerSettings != null)
+ ((IStateManager)pagerSettings).TrackViewState();
+ if (alternatingRowStyle != null)
+ ((IStateManager)alternatingRowStyle).TrackViewState();
+ if (footerStyle != null)
+ ((IStateManager)footerStyle).TrackViewState();
+ if (headerStyle != null)
+ ((IStateManager)headerStyle).TrackViewState();
+ if (pagerStyle != null)
+ ((IStateManager)pagerStyle).TrackViewState();
+ if (rowStyle != null)
+ ((IStateManager)rowStyle).TrackViewState();
+ if (editRowStyle != null)
+ ((IStateManager)editRowStyle).TrackViewState();
+ if (insertRowStyle != null)
+ ((IStateManager)insertRowStyle).TrackViewState();
+ if (emptyDataRowStyle != null)
+ ((IStateManager)emptyDataRowStyle).TrackViewState();
+ if (key != null)
+ ((IStateManager)key).TrackViewState();
if (autoFieldProperties != null) {
foreach (IStateManager sm in autoFieldProperties)
sm.TrackViewState ();
ControlStyle.LoadViewState (states [12]);
}
- void ICallbackEventHandler.RaiseCallbackEvent (string eventArgs)
+ void ICallbackEventHandler.RaiseCallbackEvent (string eventArgument)
{
- RaiseCallbackEvent (eventArgs);
+ RaiseCallbackEvent (eventArgument);
}
- protected virtual void RaiseCallbackEvent (string eventArgs)
+ protected virtual void RaiseCallbackEvent (string eventArgument)
{
- string[] clientData = eventArgs.Split ('|');
+ string[] clientData = eventArgument.Split ('|');
PageIndex = int.Parse (clientData[0]);
RaisePostBackEvent (clientData[1]);
{0}.uid = {2};
{0}.form = {3};
";
-
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
- if (EnablePagingCallbacks)
- {
- if (!Page.ClientScript.IsClientScriptIncludeRegistered (typeof(DetailsView), "DetailsView.js")) {
- string url = Page.ClientScript.GetWebResourceUrl (typeof(DetailsView), "DetailsView.js");
- Page.ClientScript.RegisterClientScriptInclude (typeof(DetailsView), "DetailsView.js", url);
+ Page page = Page;
+ if (EnablePagingCallbacks && page != null) {
+ ClientScriptManager scriptManager = page.ClientScript;
+ if (!scriptManager.IsClientScriptIncludeRegistered (typeof(DetailsView), "DetailsView.js")) {
+ string url = scriptManager.GetWebResourceUrl (typeof(DetailsView), "DetailsView.js");
+ scriptManager.RegisterClientScriptInclude (typeof(DetailsView), "DetailsView.js", url);
}
- Page.ClientScript.RegisterHiddenField (ClientID + "_Page", PageIndex.ToString ());
+ scriptManager.RegisterHiddenField (ClientID + "_Page", PageIndex.ToString ());
string cgrid = ClientID + "_data";
string script = String.Format (onPreRenderScript,
cgrid,
ClientScriptManager.GetScriptLiteral (PageIndex),
ClientScriptManager.GetScriptLiteral (UniqueID),
- Page.theForm);
+ page.theForm);
- Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);
+ scriptManager.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);
// Make sure the basic script infrastructure is rendered
- Page.ClientScript.GetCallbackEventReference (this, "null", "", "null");
- Page.ClientScript.GetPostBackClientHyperlink (this, String.Empty, true);
+ scriptManager.GetCallbackEventReference (this, "null", String.Empty, "null");
+ scriptManager.GetPostBackClientHyperlink (this, String.Empty, true);
}
}
}
}
}
-
-#endif