473,732 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"
AutoGenerateCol umns="False"
DataSourceID="d sMaterials" ShowFooter="Tru e" Width="100%"
AutoGenerateEdi tButton="True">
<Columns>
<asp:TemplateFi eld HeaderText="Mat erial:">
<FooterTemplate >
<asp:TextBox ID="txtDescript ion"
runat="server"> </asp:TextBox>
</FooterTemplate>
<EditItemTempla te>
<asp:TextBox ID="txtDescript ion" runat="server"
Text='<%# Bind("Descripti on") %>'></asp:TextBox>
</EditItemTemplat e>
<ItemTemplate >
<asp:Label ID="lblDescript ion" runat="server" Text='<%#
Bind("Descripti on") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
[etc...]

--
My BizTalk blog:
http://stevestechnotes.blogspot.com/
Jun 27 '08 #1
6 4533
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**********@g mail.comwrote in message
news:de******** *************** ***********@x35 g2000hsb.google groups.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******** *************@g mail.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
1788
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
5094
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. Thanks Hans
4
4849
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 3 options. EG OF GRIDVIEW: USUER AGE carlosg old rominat young gonzalor normal florenciat young
2
2757
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 then the header/footer vanish into thin air. If I add the header/footer onDataBound then they disappear when I do a postback with no databinding. If I add them during PreRender, then they persist, but one of my data rows is emptied for each time I...
0
8565
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 and add child grid into that row because the columns in child grid are same as parent grid and we want to align them with the cols of parent grid. 2. If there is data for child grid we show a plus image in the parent row (in the row above the...
4
26704
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
4647
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 19 records on the first results set and I can see a blank space for 3 records from the headers of the gridview to the first record it's showing. So it seems like the gridview has allocated space for all 22 records. But if I click on navigation...
2
3246
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. I need the ability to insert new rows (which is easily done with DataTable.Rows.Add(newRow) and rebinding) and then present a row with different TemplateFields for those rows (I need multiple rows in this insert state).
0
1671
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 the GridView header where I type the number of rows I want to show in insert mode. Say I type 12. 2. When I click Add, the GridView changes to insert mode showing the 12 rows ready to be filled in. I would use a custom template for insert mode. 3....
0
8944
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8773
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9234
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3259
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2177
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.