K keithb Apr 23, 2006 #1 Is there some way to persist the header when a GridView control has no rows containing data? Thanks, Keith
Is there some way to persist the header when a GridView control has no rows containing data? Thanks, Keith
J JudahReeves May 23, 2006 #2 You can subclass the GridView and add this to OnDataBound: this.Controls.Add(new Table()); GridViewRow header = this.CreateRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal); DataControlField[] fields = new DataControlField[this.Columns.Count]; this.InitializeRow(header, fields); ((Table)this.Controls[0]).Rows.Add(header);
You can subclass the GridView and add this to OnDataBound: this.Controls.Add(new Table()); GridViewRow header = this.CreateRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal); DataControlField[] fields = new DataControlField[this.Columns.Count]; this.InitializeRow(header, fields); ((Table)this.Controls[0]).Rows.Add(header);
J JudahReeves May 23, 2006 #3 Noticed something: this.Controls.Add(new Table()); GridViewRow header = this.CreateRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal); DataControlField[] fields = new DataControlField[this.Columns.Count]; this.Columns.CopyTo(fields, 0); this.InitializeRow(header, fields); ((Table)this.Controls[0]).Rows.Add(header);
Noticed something: this.Controls.Add(new Table()); GridViewRow header = this.CreateRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal); DataControlField[] fields = new DataControlField[this.Columns.Count]; this.Columns.CopyTo(fields, 0); this.InitializeRow(header, fields); ((Table)this.Controls[0]).Rows.Add(header);