473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GridView not Showing Headers When there are No Rows

Hi,

I'm trying to get my DataGrid to show headers and footers when no rows are
returned from the datasource. Below is code that shows the first
TemplateField. Is there an easy way to get at least the footer to show? I
want to be able to insert a new row using the footer. Thanks...

<asp:GridView ID="gvMaterials" runat="server"
AutoGenerateColumns="False"
DataSourceID="dsMaterials" ShowFooter="True" Width="100%"
AutoGenerateEditButton="True">
<Columns>
<asp:TemplateField HeaderText="Material:">
<FooterTemplate>
<asp:TextBox ID="txtDescription"
runat="server"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDescription" runat="server"
Text='<%# Bind("Description") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblDescription" runat="server" Text='<%#
Bind("Description") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
[etc...]

--
My BizTalk blog:
http://stevestechnotes.blogspot.com/
Jun 27 '08 #1
6 4497
What is the actual data-source - i.e. the object you give to
dsMaterials?

I'm going to go out on a limb and guess that it is an ArrayList?

To get metadata, it needs some clue to the data. There are various
ways it can do this - the simplest is a typed indexer - i.e. a "public
T this[int index] {get;}" for some T (doesn't have to be generics...).

In the absense of a typed indexer, the metadata of the first item is
used. If there aren't any items, you're scuppered.

(there are also things like ITypedList and IListSource that are taken
into account, but these are more complex)
Jun 27 '08 #2
Oops; I forgot to say! If you are using an ArrayList, the easiest way
to fix this is to use a List<Tor BindingList<T>, or perhaps even
just an array: T[]

If you aren't using ArrayList, then tell us what you *are* using as
the data-source.

Marc
Jun 27 '08 #3
I'm using a SqlDataSource that calls a stored procedure -- which contains a
simple "SELECT * FROM Tablex WHERE ...".

Thanks,
Steve

"Marc Gravell" <ma**********@gmail.comwrote in message
news:de**********************************@x35g2000 hsb.googlegroups.com...
What is the actual data-source - i.e. the object you give to
dsMaterials?

Jun 27 '08 #4
Hmmm... I would have expected to work. I'm sorry, but I don't know. If
you don't get any other takers, I would recommend posting on an asp
group, since there will be many GridView experts there...

Marc
Jun 27 '08 #5
HI Steve,

Gridview does not display anything if database is returning zero number of rows.
In case you still want to display it then you can enter some dummy rows in an arraylist or dataset and then connect it to gridview and then hide that dummy row in grid , it will display only header and footer now.
Jun 27 '08 #6
Thanks for your input, Sunil. I'll try that.

- Steve

<Sunil Lakshkarwrote in message news:20*********************@gmail.com...
HI Steve,

Gridview does not display anything if database is returning zero number of
rows.
In case you still want to display it then you can enter some dummy rows in
an arraylist or dataset and then connect it to gridview and then hide that
dummy row in grid , it will display only header and footer now.

Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tshad | last post by:
I have a Datagrid that has no rows in it, but I want the title to show, and they aren't. Is there a way to make them visible even if the Datagrid is empty? Thanks, Tom
4
by: Hans Merkl | last post by:
Hi, Is there a way to show the column headers of a GridView control even if there is no data? The only thing I see is the EmptyDataTemplate but I would also like to display the column headers. ...
4
by: Marcos Beccar Varela | GamaCom Argentina | last post by:
Hello Everyone. I need to use a gridview, that when I use the Update command one of the colums, instead of showing a textbox where the user can write, I need a combobox (listobx), where there are...
2
by: Flinky Wisty Pomm | last post by:
Hi all, I've got a really annoying problem that I need to fix sharpish. I've got a GridView derived control which has a templated header and footer. It works wonderfully on the first render but...
0
by: Innova | last post by:
Hi, We are working on a gridview inside the gridview (parent-child) scenario. The data of child grid will depend on the data of parent. Objectives: 1.Add new row in parent grid after each row...
4
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
2
by: manukaleel | last post by:
VB.NET(ASP.NET 2.0)-WEB .NET PLATFORM GridView Page Size is not working Hi, I have set the pagesize of a gridview to 22(both in aspx file as well as in the .vb file. But it's showing only...
2
by: DC | last post by:
Hi, I am using a GridView to present data in a DataTable, which I store only in ViewState and when the user hits the "OK" button the rows in the DataTable will be used to execute transactions. ...
0
by: Andy B | last post by:
I need to take an existing GridView that connects to a database and gets rows from a table and force it to show x rows in the insert mode. This is what should happen: 1. There is a TextBox in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.