Merge pull request #1345 from mattleibow/websocket-continuation-frame-fix
[mono.git] / mcs / class / System.Web / Test / mainsoft / NunitWebResources / BoundField_Bug646505.aspx.cs
1 using System;
2 using System.Web.UI.WebControls;
3
4 namespace MonoBoundFieldCompatibilityIssue
5 {
6         public partial class _Default : System.Web.UI.Page
7         {
8                 #region [ -- Custom Column Definition -- ]
9
10                 /// <summary>
11                 /// Custom Column for the GridView
12                 /// </summary>
13                 class CustomColumn : BoundField
14                 {
15                         protected override void InitializeDataCell (DataControlFieldCell cell, DataControlRowState rowState)
16                         {
17                                 if ((rowState & DataControlRowState.Edit) != DataControlRowState.Normal) {
18                                         TextBox textBox = new TextBox ();
19                                         cell.Controls.Add (textBox);
20                                         textBox.DataBinding += OnDataBindField;
21                                 } else
22                                         base.InitializeDataCell (cell, rowState);
23                         }
24                 }
25
26                 #endregion
27
28                 protected void Page_Load (object sender, EventArgs e)
29                 {
30                         if (IsPostBack) return;
31                         BindGridView ();
32                 }
33
34                 protected void OnGridViewInit (object sender, EventArgs e)
35                 {
36                         CustomColumn column = new CustomColumn (); 
37                         column.DataField = BoundField.ThisExpression;
38                         gridView.Columns.Add (column);
39                 }
40
41                 protected void OnGridViewRowEditing (object sender, GridViewEditEventArgs e)
42                 {
43                         gridView.EditIndex = e.NewEditIndex;
44                         BindGridView ();
45                 }
46
47                 protected void OnGridViewEditCancelling (object sender, EventArgs e)
48                 {
49                         gridView.EditIndex = -1;
50                         BindGridView ();
51                 }
52
53                 private void BindGridView ()
54                 {
55                         gridView.DataSource = new bool [2];
56                         gridView.DataBind ();
57                 }
58         }
59 }