Empty results hide GridView headers

J

jean-pierre.riehl

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top