namespace System.Web.UI.WebControls
{
- [DesignerAttribute ("System.Web.UI.Design.WebControls.GridViewDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
+ [SupportsEventValidation]
+ [DesignerAttribute ("System.Web.UI.Design.WebControls.GridViewDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
[ControlValuePropertyAttribute ("SelectedValue")]
[DefaultEventAttribute ("SelectedIndexChanged")]
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- public class GridView: CompositeDataBoundControl, ICallbackEventHandler, ICallbackContainer
+ public class GridView: CompositeDataBoundControl, ICallbackEventHandler, ICallbackContainer, IPostBackEventHandler, IPostBackContainer
{
Table table;
GridViewRowCollection rows;
- GridViewRow headerRow;
- GridViewRow footerRow;
GridViewRow bottomPagerRow;
GridViewRow topPagerRow;
DataControlFieldCollection columns;
PagerSettings pagerSettings;
+ TableStyle style;
TableItemStyle alternatingRowStyle;
TableItemStyle editRowStyle;
TableItemStyle emptyDataRowStyle;
DataKeyArray keys;
DataKey oldEditValues;
AutoGeneratedFieldProperties[] autoFieldProperties;
+ string [] dataKeyNames = null;
readonly string[] emptyKeys = new string[0];
private static readonly object PageIndexChangedEvent = new object();
// Control state
int pageIndex;
- int pageCount = -1;
+ int pageCount = 0;
int selectedIndex = -1;
int editIndex = -1;
SortDirection sortDirection = SortDirection.Ascending;
- string sortExpression;
+ string sortExpression = string.Empty;
public GridView ()
{
[WebCategoryAttribute ("Paging")]
[DefaultValueAttribute (false)]
- public bool AllowPaging {
+ public virtual bool AllowPaging {
get {
object ob = ViewState ["AllowPaging"];
if (ob != null) return (bool) ob;
[WebCategoryAttribute ("Behavior")]
[DefaultValueAttribute (false)]
- public bool AllowSorting {
+ public virtual bool AllowSorting {
get {
object ob = ViewState ["AllowSorting"];
if (ob != null) return (bool) ob;
}
}
- [WebCategoryAttribute ("Styles")]
+ [WebCategoryAttribute ("Styles")]
[PersistenceMode (PersistenceMode.InnerProperty)]
[NotifyParentProperty (true)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public virtual TableItemStyle AlternatingRowStyle {
+ public TableItemStyle AlternatingRowStyle {
get {
if (alternatingRowStyle == null) {
alternatingRowStyle = new TableItemStyle ();
[UrlPropertyAttribute]
[WebCategoryAttribute ("Appearance")]
[DefaultValueAttribute ("")]
- [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+ [EditorAttribute ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
public virtual string BackImageUrl {
get {
object ob = ViewState ["BackImageUrl"];
[WebCategoryAttribute ("Accessibility")]
[DefaultValueAttribute ("")]
[LocalizableAttribute (true)]
- public string Caption {
+ public virtual string Caption {
get {
object ob = ViewState ["Caption"];
if (ob != null) return (string) ob;
}
}
- [EditorAttribute ("System.Web.UI.Design.WebControls.DataControlFieldTypeEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+ [EditorAttribute ("System.Web.UI.Design.WebControls.DataControlFieldTypeEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
[MergablePropertyAttribute (false)]
[PersistenceModeAttribute (PersistenceMode.InnerProperty)]
[DefaultValueAttribute (null)]
[DefaultValueAttribute (null)]
[WebCategoryAttribute ("Data")]
[TypeConverter (typeof(StringArrayConverter))]
- [EditorAttribute ("System.Web.UI.Design.WebControls.DataFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+ [EditorAttribute ("System.Web.UI.Design.WebControls.DataFieldEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
public virtual string[] DataKeyNames
{
get {
- object o = ViewState ["DataKeyNames"];
- if (o != null) return (string[]) o;
+ if (dataKeyNames != null)
+ return dataKeyNames;
return emptyKeys;
}
set {
- ViewState ["DataKeyNames"] = value;
+ dataKeyNames = value;
RequireBinding ();
}
}
[WebCategoryAttribute ("Misc")]
[DefaultValueAttribute (-1)]
- public int EditIndex {
+ public virtual int EditIndex {
get {
return editIndex;
}
}
}
- [WebCategoryAttribute ("Styles")]
+ [WebCategoryAttribute ("Styles")]
[PersistenceMode (PersistenceMode.InnerProperty)]
[NotifyParentProperty (true)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public virtual TableItemStyle EditRowStyle {
+ public TableItemStyle EditRowStyle {
get {
if (editRowStyle == null) {
editRowStyle = new TableItemStyle ();
}
}
- [WebCategoryAttribute ("Styles")]
+ [WebCategoryAttribute ("Styles")]
[PersistenceMode (PersistenceMode.InnerProperty)]
[NotifyParentProperty (true)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public virtual TableItemStyle EmptyDataRowStyle {
+ public TableItemStyle EmptyDataRowStyle {
get {
if (emptyDataRowStyle == null) {
emptyDataRowStyle = new TableItemStyle ();
}
[DefaultValue (null)]
- [TemplateContainer (typeof(GridView), BindingDirection.OneWay)]
+ [TemplateContainer (typeof(GridViewRow), BindingDirection.OneWay)]
[PersistenceMode (PersistenceMode.InnerProperty)]
- [Browsable (false)]
- public ITemplate EmptyDataTemplate {
+ [Browsable (false)]
+ public virtual ITemplate EmptyDataTemplate {
get { return emptyDataTemplate; }
set { emptyDataTemplate = value; RequireBinding (); }
}
[BrowsableAttribute (false)]
public virtual GridViewRow FooterRow {
get {
- if (footerRow == null)
- footerRow = CreateRow (0, 0, DataControlRowType.Footer, DataControlRowState.Normal);
- return footerRow;
+ if (table != null) {
+ for (int index = table.Rows.Count - 1; index >= 0; index--) {
+ GridViewRow row = (GridViewRow) table.Rows [index];
+ switch (row.RowType) {
+ case DataControlRowType.Separator:
+ case DataControlRowType.Pager:
+ continue;
+ case DataControlRowType.Footer:
+ return row;
+ default:
+ break;
+ }
+ }
+ }
+ return null;
}
}
- [WebCategoryAttribute ("Styles")]
+ [WebCategoryAttribute ("Styles")]
[PersistenceMode (PersistenceMode.InnerProperty)]
[NotifyParentProperty (true)]
[DefaultValue (null)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public virtual TableItemStyle FooterStyle {
+ public TableItemStyle FooterStyle {
get {
if (footerStyle == null) {
footerStyle = new TableItemStyle ();
[BrowsableAttribute (false)]
public virtual GridViewRow HeaderRow {
get {
- if (headerRow == null)
- headerRow = CreateRow (0, 0, DataControlRowType.Header, DataControlRowState.Normal);
- return headerRow;
+ if (table != null) {
+ for (int index = 0, total = table.Rows.Count; index < total; index++) {
+ GridViewRow row = (GridViewRow) table.Rows [index];
+ switch (row.RowType) {
+ case DataControlRowType.Separator:
+ case DataControlRowType.Pager:
+ continue;
+ case DataControlRowType.Header:
+ return row;
+ default:
+ break;
+ }
+ }
+ }
+ return null;
}
}
- [WebCategoryAttribute ("Styles")]
+ [WebCategoryAttribute ("Styles")]
[PersistenceMode (PersistenceMode.InnerProperty)]
[NotifyParentProperty (true)]
[DefaultValue (null)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public virtual TableItemStyle HeaderStyle {
+ public TableItemStyle HeaderStyle {
get {
if (headerStyle == null) {
headerStyle = new TableItemStyle ();
}
}
+ [Category ("Layout")]
[DefaultValueAttribute (HorizontalAlign.NotSet)]
public virtual HorizontalAlign HorizontalAlign {
get {
[BrowsableAttribute (false)]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
- public int PageCount {
+ public virtual int PageCount {
get {
- if (pageCount != -1) return pageCount;
+ if (pageCount != 0) return pageCount;
EnsureDataBound ();
return pageCount;
}
[WebCategoryAttribute ("Paging")]
[BrowsableAttribute (true)]
[DefaultValueAttribute (0)]
- public int PageIndex {
+ public virtual int PageIndex {
get {
return pageIndex;
}
[DefaultValueAttribute (10)]
[WebCategoryAttribute ("Paging")]
- public int PageSize {
+ public virtual int PageSize {
get {
object ob = ViewState ["PageSize"];
if (ob != null) return (int) ob;
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Content)]
[NotifyParentPropertyAttribute (true)]
[PersistenceModeAttribute (PersistenceMode.InnerProperty)]
- public PagerSettings PagerSettings {
+ public virtual PagerSettings PagerSettings {
get {
if (pagerSettings == null) {
pagerSettings = new PagerSettings (this);
}
}
- [WebCategoryAttribute ("Styles")]
+ [WebCategoryAttribute ("Styles")]
[PersistenceMode (PersistenceMode.InnerProperty)]
[NotifyParentProperty (true)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public virtual TableItemStyle PagerStyle {
+ public TableItemStyle PagerStyle {
get {
if (pagerStyle == null) {
pagerStyle = new TableItemStyle ();
[DefaultValue (null)]
- [TemplateContainer (typeof(GridView), BindingDirection.OneWay)]
+ /* DataControlPagerCell isnt specified in the docs */
+ //[TemplateContainer (typeof(DataControlPagerCell), BindingDirection.OneWay)]
[PersistenceMode (PersistenceMode.InnerProperty)]
- [Browsable (false)]
- public ITemplate PagerTemplate {
+ [Browsable (false)]
+ public virtual ITemplate PagerTemplate {
get { return pagerTemplate; }
set { pagerTemplate = value; RequireBinding (); }
}
[DefaultValueAttribute ("")]
[WebCategoryAttribute ("Accessibility")]
-// [TypeConverterAttribute (typeof(System.Web.UI.Design.DataColumnSelectionConverter)]
+ // [TypeConverterAttribute (typeof(System.Web.UI.Design.DataColumnSelectionConverter)]
public virtual string RowHeaderColumn {
get {
object ob = ViewState ["RowHeaderColumn"];
}
}
- [WebCategoryAttribute ("Styles")]
+ [WebCategoryAttribute ("Styles")]
[PersistenceMode (PersistenceMode.InnerProperty)]
[NotifyParentProperty (true)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public virtual TableItemStyle RowStyle {
+ public TableItemStyle RowStyle {
get {
if (rowStyle == null) {
rowStyle = new TableItemStyle ();
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public virtual DataKey SelectedDataKey {
get {
+ if (DataKeys == null)
+ throw new InvalidOperationException ("DataKeys");
+
if (selectedIndex >= 0 && selectedIndex < DataKeys.Count) {
return DataKeys [selectedIndex];
} else
[BindableAttribute (true)]
[DefaultValueAttribute (-1)]
- public int SelectedIndex {
+ public virtual int SelectedIndex {
get {
return selectedIndex;
}
set {
- if (selectedIndex >= 0 && selectedIndex < Rows.Count) {
+ if (Rows != null && selectedIndex >= 0 && selectedIndex < Rows.Count) {
int oldIndex = selectedIndex;
selectedIndex = -1;
Rows [oldIndex].RowState = GetRowState (oldIndex);
}
selectedIndex = value;
- if (selectedIndex >= 0 && selectedIndex < Rows.Count) {
+ if (Rows != null && selectedIndex >= 0 && selectedIndex < Rows.Count) {
Rows [selectedIndex].RowState = GetRowState (selectedIndex);
}
}
}
}
- [WebCategoryAttribute ("Styles")]
+ [WebCategoryAttribute ("Styles")]
[PersistenceMode (PersistenceMode.InnerProperty)]
[NotifyParentProperty (true)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
- public virtual TableItemStyle SelectedRowStyle {
+ public TableItemStyle SelectedRowStyle {
get {
if (selectedRowStyle == null) {
selectedRowStyle = new TableItemStyle ();
}
[BrowsableAttribute (false)]
- public virtual object SelectedValue {
+ public object SelectedValue {
get {
if (SelectedDataKey != null)
return SelectedDataKey.Value;
protected virtual ICollection CreateColumns (PagedDataSource dataSource, bool useDataSource)
{
ArrayList fields = new ArrayList ();
+ fields.AddRange (Columns);
if (AutoGenerateEditButton || AutoGenerateDeleteButton || AutoGenerateSelectButton) {
CommandField field = new CommandField ();
}
}
- fields.AddRange (Columns);
-
return fields;
}
object fitem = null;
prop_type = null;
PropertyInfo prop_item = source.DataSource.GetType().GetProperty("Item",
- BindingFlags.Instance | BindingFlags.Static |
- BindingFlags.Public, null, null,
- new Type[] { typeof(int) }, null);
+ BindingFlags.Instance | BindingFlags.Static |
+ BindingFlags.Public, null, null,
+ new Type[] { typeof(int) }, null);
if (prop_item != null) {
prop_type = prop_item.PropertyType;
table.Rows.Add (topPagerRow);
}
- if (ShowHeader) {
- headerRow = CreateRow (0, 0, DataControlRowType.Header, DataControlRowState.Normal);
- table.Rows.Add (headerRow);
- InitializeRow (headerRow, fields);
- }
+ GridViewRow headerRow = CreateRow (0, 0, DataControlRowType.Header, DataControlRowState.Normal);
+ table.Rows.Add (headerRow);
+ InitializeRow (headerRow, fields);
foreach (object obj in dataSource) {
DataControlRowState rstate = GetRowState (list.Count);
table.Rows.Add (row);
InitializeRow (row, fields);
if (dataBinding) {
-// row.DataBind ();
+ row.DataBind ();
OnRowDataBound (new GridViewRowEventArgs (row));
if (EditIndex == row.RowIndex)
oldEditValues = new DataKey (GetRowValues (row, false, true));
if (list.Count == 0)
table.Rows.Add (CreateEmptyrRow (fields.Length));
- if (ShowFooter) {
- footerRow = CreateRow (0, 0, DataControlRowType.Footer, DataControlRowState.Normal);
- table.Rows.Add (footerRow);
- InitializeRow (footerRow, fields);
- }
+ GridViewRow footerRow = CreateRow (0, 0, DataControlRowType.Footer, DataControlRowState.Normal);
+ table.Rows.Add (footerRow);
+ InitializeRow (footerRow, fields);
if (showPager && PagerSettings.Position == PagerPosition.Bottom || PagerSettings.Position == PagerPosition.TopAndBottom) {
bottomPagerRow = CreatePagerRow (fields.Length, dataSource);
rows = new GridViewRowCollection (list);
keys = new DataKeyArray (keyList);
-
- if (dataBinding)
- DataBind (false);
return dataSource.DataSourceCount;
}
+
+ [MonoTODO]
+ protected override Style CreateControlStyle ()
+ {
+ style = new TableStyle (ViewState);
+ style.GridLines = GridLines.Both;
+ style.CellSpacing = 0;
+ return style;
+ }
DataControlRowState GetRowState (int index)
{
protected virtual void InitializePager (GridViewRow row, int columnSpan, PagedDataSource dataSource)
{
TableCell cell = new TableCell ();
- cell.ColumnSpan = columnSpan;
+ if (columnSpan > 1)
+ cell.ColumnSpan = columnSpan;
if (pagerTemplate != null)
pagerTemplate.InstantiateIn (cell);
bool accessibleHeader = false;
switch (row.RowType) {
- case DataControlRowType.Header:
- ctype = DataControlCellType.Header;
- accessibleHeader = UseAccessibleHeader;
- break;
- case DataControlRowType.Footer:
- ctype = DataControlCellType.Footer;
- break;
- default:
- ctype = DataControlCellType.DataCell;
- break;
+ case DataControlRowType.Header:
+ ctype = DataControlCellType.Header;
+ accessibleHeader = UseAccessibleHeader;
+ break;
+ case DataControlRowType.Footer:
+ ctype = DataControlCellType.Footer;
+ break;
+ default:
+ ctype = DataControlCellType.DataCell;
+ break;
}
for (int n=0; n<fields.Length; n++) {
base.DataBind ();
}
- protected override void PerformDataBinding (IEnumerable data)
+ protected internal override void PerformDataBinding (IEnumerable data)
{
base.PerformDataBinding (data);
}
+
+ [MonoTODO]
+ protected internal virtual void PrepareControlHierarchy ()
+ {
+ throw new NotImplementedException ();
+ }
- protected override void OnInit (EventArgs e)
+ protected internal override void OnInit (EventArgs e)
{
Page.RegisterRequiresControlState (this);
base.OnInit (e);
GridViewCommandEventArgs args = e as GridViewCommandEventArgs;
if (args != null) {
OnRowCommand (args);
- ProcessEvent (args.CommandName, args.CommandArgument as string);
+ string param = args.CommandArgument as string;
+ if (param == null || param.Length == 0) {
+ GridViewRow row = args.Row;
+ if (row != null)
+ param = row.RowIndex.ToString();
+ }
+ ProcessEvent (args.CommandName, param);
}
return base.OnBubbleEvent (source, e);
}
+ void IPostBackEventHandler.RaisePostBackEvent (string eventArgument)
+ {
+ RaisePostBackEvent (eventArgument);
+ }
+
// This is prolly obsolete
protected virtual void RaisePostBackEvent (string eventArgument)
{
{
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:
- if (PageIndex < PageCount - 1) newIndex = PageIndex + 1;
- break;
- case DataControlCommands.PreviousPageCommandArgument:
- if (PageIndex > 0) newIndex = PageIndex - 1;
- break;
- default:
- newIndex = int.Parse (param) - 1;
- break;
- }
- ShowPage (newIndex);
- break;
-
+ case DataControlCommands.PageCommandName:
+ int newIndex = -1;
+ switch (param) {
case DataControlCommands.FirstPageCommandArgument:
- ShowPage (0);
+ newIndex = 0;
break;
-
case DataControlCommands.LastPageCommandArgument:
- ShowPage (PageCount - 1);
+ newIndex = PageCount - 1;
break;
-
case DataControlCommands.NextPageCommandArgument:
- if (PageIndex < PageCount - 1)
- ShowPage (PageIndex + 1);
+ if (PageIndex < PageCount - 1) newIndex = PageIndex + 1;
break;
-
case DataControlCommands.PreviousPageCommandArgument:
- if (PageIndex > 0)
- ShowPage (PageIndex - 1);
+ if (PageIndex > 0) newIndex = PageIndex - 1;
break;
-
- case DataControlCommands.SelectCommandName:
- SelectRow (int.Parse (param));
+ default:
+ newIndex = int.Parse (param) - 1;
break;
+ }
+ ShowPage (newIndex);
+ break;
- case DataControlCommands.EditCommandName:
- EditRow (int.Parse (param));
- break;
+ case DataControlCommands.FirstPageCommandArgument:
+ ShowPage (0);
+ break;
+
+ case DataControlCommands.LastPageCommandArgument:
+ ShowPage (PageCount - 1);
+ break;
- case DataControlCommands.UpdateCommandName:
- UpdateRow (EditIndex, true);
- break;
+ case DataControlCommands.NextPageCommandArgument:
+ if (PageIndex < PageCount - 1)
+ ShowPage (PageIndex + 1);
+ break;
+
+ case DataControlCommands.PreviousPageCommandArgument:
+ if (PageIndex > 0)
+ ShowPage (PageIndex - 1);
+ break;
- case DataControlCommands.CancelCommandName:
- CancelEdit ();
- break;
+ case DataControlCommands.SelectCommandName:
+ SelectRow (int.Parse (param));
+ break;
- case DataControlCommands.DeleteCommandName:
- DeleteRow (int.Parse (param));
- break;
+ case DataControlCommands.EditCommandName:
+ EditRow (int.Parse (param));
+ break;
- case DataControlCommands.SortCommandName:
- Sort (param);
- break;
+ case DataControlCommands.UpdateCommandName:
+ UpdateRow (EditIndex, true);
+ break;
+
+ case DataControlCommands.CancelCommandName:
+ CancelEdit ();
+ break;
+
+ case DataControlCommands.DeleteCommandName:
+ DeleteRow (int.Parse (param));
+ break;
+
+ case DataControlCommands.SortCommandName:
+ Sort (param);
+ break;
}
}
Sort (newSortExpression, newDirection);
}
- public void Sort (string newSortExpression, SortDirection newSortDirection)
+ public virtual void Sort (string newSortExpression, SortDirection newSortDirection)
{
GridViewSortEventArgs args = new GridViewSortEventArgs (newSortExpression, newSortDirection);
OnSorting (args);
EndRowEdit ();
}
- bool UpdateCallback (int recordsAffected, Exception exception)
+ bool UpdateCallback (int recordsAffected, Exception exception)
{
GridViewUpdatedEventArgs dargs = new GridViewUpdatedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditOldValues, currentEditNewValues);
OnRowUpdated (dargs);
return dargs.ExceptionHandled;
}
- public void DeleteRow (int rowIndex)
+ public virtual void DeleteRow (int rowIndex)
{
GridViewRow row = Rows [rowIndex];
currentEditRowKeys = DataKeys [rowIndex].Values;
}
}
- bool DeleteCallback (int recordsAffected, Exception exception)
+ bool DeleteCallback (int recordsAffected, Exception exception)
{
GridViewDeletedEventArgs dargs = new GridViewDeletedEventArgs (recordsAffected, exception, currentEditRowKeys, currentEditNewValues);
OnRowDeleted (dargs);
editIndex = (int) state[4];
sortExpression = (string) state[5];
sortDirection = (SortDirection) state[6];
+ DataKeyNames = (string []) state [7];
}
protected internal override object SaveControlState ()
{
object bstate = base.SaveControlState ();
return new object[] {
- bstate, pageIndex, pageCount, selectedIndex, editIndex, sortExpression, sortDirection
- };
+ bstate, pageIndex, pageCount, selectedIndex, editIndex, sortExpression, sortDirection, DataKeyNames
+ };
}
protected override void TrackViewState()
if (states[12] != null && oldEditValues != null) ((IStateManager)oldEditValues).LoadViewState (states[12]);
}
- string ICallbackEventHandler.RaiseCallbackEvent (string eventArgs)
+ void ICallbackEventHandler.RaiseCallbackEvent (string eventArgs)
{
- return RaiseCallbackEvent (eventArgs);
+ RaiseCallbackEvent (eventArgs);
}
- protected virtual string RaiseCallbackEvent (string eventArgs)
+ string callbackResult;
+ protected virtual void RaiseCallbackEvent (string eventArgs)
{
string[] clientData = eventArgs.Split ('|');
pageIndex = int.Parse (clientData[0]);
HtmlTextWriter writer = new HtmlTextWriter (sw);
RenderGrid (writer);
- return sw.ToString ();
+ callbackResult = sw.ToString ();
}
+ string ICallbackEventHandler.GetCallbackResult ()
+ {
+ return GetCallbackResult ();
+ }
+
+ protected virtual string GetCallbackResult ()
+ {
+ return callbackResult;
+ }
+
string ICallbackContainer.GetCallbackScript (IButtonControl control, string argument)
{
return GetCallbackScript (control, argument);
return null;
}
- protected override void OnPreRender (EventArgs e)
+ [MonoTODO]
+ protected override void OnPagePreLoad (object sender, EventArgs e)
+ {
+ base.OnPagePreLoad (sender, e);
+ }
+
+ protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
Page.ClientScript.RegisterStartupScript (typeof(TreeView), this.UniqueID, script, true);
// Make sure the basic script infrastructure is rendered
- Page.ClientScript.GetCallbackEventReference (this, "null", "", "null");
+ Page.ClientScript.GetCallbackEventReference (this, "null", "", "null");
Page.ClientScript.GetPostBackClientHyperlink (this, "");
}
}
- protected override void Render (HtmlTextWriter writer)
+ protected internal override void Render (HtmlTextWriter writer)
{
if (EnableSortingAndPagingCallbacks)
base.RenderBeginTag (writer);
+ else
+ writer.RenderBeginTag (HtmlTextWriterTag.Div);
RenderGrid (writer);
if (EnableSortingAndPagingCallbacks)
base.RenderEndTag (writer);
+ else
+ writer.RenderEndTag ();
}
void RenderGrid (HtmlTextWriter writer)
{
- switch (GridLines) {
- case GridLines.Horizontal:
- writer.AddAttribute (HtmlTextWriterAttribute.Rules, "rows");
- writer.AddAttribute (HtmlTextWriterAttribute.Border, "1");
- break;
- case GridLines.Vertical:
- writer.AddAttribute (HtmlTextWriterAttribute.Rules, "cols");
- writer.AddAttribute (HtmlTextWriterAttribute.Border, "1");
- break;
- case GridLines.Both:
- writer.AddAttribute (HtmlTextWriterAttribute.Rules, "all");
- writer.AddAttribute (HtmlTextWriterAttribute.Border, "1");
- break;
- default:
- writer.AddAttribute (HtmlTextWriterAttribute.Border, "0");
- break;
- }
-
- writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0");
- writer.AddStyleAttribute (HtmlTextWriterStyle.BorderCollapse, "collapse");
+ if (table == null)
+ return;
+
+ table.GridLines = GridLines;
table.RenderBeginTag (writer);
foreach (GridViewRow row in table.Rows)
{
switch (row.RowType) {
- case DataControlRowType.Header:
- if (headerStyle != null)headerStyle.AddAttributesToRender (writer, row);
- break;
- case DataControlRowType.Footer:
- if (footerStyle != null) footerStyle.AddAttributesToRender (writer, row);
- break;
- case DataControlRowType.Pager:
- if (pagerStyle != null) pagerStyle.AddAttributesToRender (writer, row);
- break;
- case DataControlRowType.EmptyDataRow:
- if (emptyDataRowStyle != null) emptyDataRowStyle.AddAttributesToRender (writer, row);
- break;
- default:
- if (rowStyle != null) rowStyle.AddAttributesToRender (writer, row);
- break;
+ case DataControlRowType.Header:
+ if (!ShowHeader) continue;
+ if (headerStyle != null)headerStyle.AddAttributesToRender (writer, row);
+ break;
+ case DataControlRowType.Footer:
+ if (!ShowFooter) continue;
+ if (footerStyle != null) footerStyle.AddAttributesToRender (writer, row);
+ break;
+ case DataControlRowType.Pager:
+ if (pagerStyle != null) pagerStyle.AddAttributesToRender (writer, row);
+ break;
+ case DataControlRowType.EmptyDataRow:
+ if (emptyDataRowStyle != null) emptyDataRowStyle.AddAttributesToRender (writer, row);
+ break;
+ default:
+ break;
}
+ if ((row.RowState & DataControlRowState.Normal) != 0 && rowStyle != null)
+ rowStyle.AddAttributesToRender (writer, row);
if ((row.RowState & DataControlRowState.Alternate) != 0 && alternatingRowStyle != null)
alternatingRowStyle.AddAttributesToRender (writer, row);
if ((row.RowState & DataControlRowState.Edit) != 0 && editRowStyle != null)
if (fcell != null) {
Style cellStyle = null;
switch (row.RowType) {
- case DataControlRowType.Header: cellStyle = fcell.ContainingField.HeaderStyle; break;
- case DataControlRowType.Footer: cellStyle = fcell.ContainingField.FooterStyle; break;
- default: cellStyle = fcell.ContainingField.ItemStyle; break;
+ case DataControlRowType.Header: cellStyle = fcell.ContainingField.HeaderStyle; break;
+ case DataControlRowType.Footer: cellStyle = fcell.ContainingField.FooterStyle; break;
+ default: cellStyle = fcell.ContainingField.ItemStyle; break;
}
if (cellStyle != null)
cellStyle.AddAttributesToRender (writer, cell);
}
table.RenderEndTag (writer);
}
+
+ [MonoTODO]
+ PostBackOptions IPostBackContainer.GetPostBackOptions (IButtonControl control)
+ {
+ PostBackOptions pbo = new PostBackOptions (this, control.CommandName + "$" + control.CommandArgument);
+ return pbo;
+ }
}
}