|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Empty results hide GridView headersWith ASP.NET 2.0 (I don't remember about a such problem in 1.1), GridView control has a strange rendering rule. When dataview is empty (no data or data fitered), GridView control ONLY renders <EmptyDataTemplate> (or EmptyDataText property). It is impossible to render columns headers (and filter controls created with it for example). Using Reflector, we can see that logic in CreateChildControls : ------ case 0: //number of row in DataView if ((this.EmptyDataTemplate != null) || (this.EmptyDataText.Length > 0)) { this.CreateRow(-1, -1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal, dataBinding, null, fieldArray1, collection4, null); } else { this.Controls.Clear(); } this._storedDataValid = false; this._firstDataRow = null; return 0; -------- Nothing is rendered except an "empty" row. I found some workarounds on Internet (many guys have the same problem) but none of them satisfy me. They are : -Create an empty data row in DataSource (possible mistake between real data and fake data in all layers) -Manually render Headers on RowCreated event (use of protected CreateRow method or duplicate some Framework code) My questions are : -Is MS aware about that "problem" ? -Which workaround is recommanded by MS ? -Will it be fixed in next Service Pack ? (and when) Jean-Pierre Riehl Bewise (http://www.bewise.fr) Ingénieur Consultant Use
http://blogs.claritycon.com/blogs/kevin_marshall/archive/2006/02/28/247.aspx -- Show quoteHide quotethanks - dave david_at_windward_dot_net http://www.windwardreports.com Cubicle Wars - http://www.windwardreports.com/film.htm "jean-pierre.ri***@bewise.fr" wrote: > Hi, > > With ASP.NET 2.0 (I don't remember about a such problem in 1.1), > GridView control has a strange rendering rule. When dataview is empty > (no data or data fitered), GridView control ONLY renders > <EmptyDataTemplate> (or EmptyDataText property). It is impossible to > render columns headers (and filter controls created with it for > example). > Using Reflector, we can see that logic in CreateChildControls : > ------ > case 0: //number of row in DataView > if ((this.EmptyDataTemplate != null) || (this.EmptyDataText.Length > > 0)) > { > this.CreateRow(-1, -1, DataControlRowType.EmptyDataRow, > DataControlRowState.Normal, dataBinding, null, fieldArray1, > collection4, null); > } > > else > { > this.Controls.Clear(); > } > this._storedDataValid = false; > this._firstDataRow = null; > return 0; > -------- > Nothing is rendered except an "empty" row. > > I found some workarounds on Internet (many guys have the same problem) > but none of them satisfy me. They are : > -Create an empty data row in DataSource (possible mistake between > real data and fake data in all layers) > -Manually render Headers on RowCreated event (use of protected > CreateRow method or duplicate some Framework code) > > My questions are : > -Is MS aware about that "problem" ? > -Which workaround is recommanded by MS ? > -Will it be fixed in next Service Pack ? (and when) > > > Jean-Pierre Riehl > Bewise (http://www.bewise.fr) > Ingénieur Consultant > >
Need button control that...
auto-size textbox 3 step wizard - ignore last step Can't duplicate ID in subclassed GridView menu question all bitmap button in grid? how to validate input of a detailsview? Anyone have APP_LocalResources resx files for the MS controls... Datagrid template column GridView RowComand event Issue |
|||||||||||||||||||||||