Forms Data Controls :: Shows A Gridview (headers) Without Having Records?
May 11, 2010
I have written a code from here http://www.aspsnippets.com/Articles/Display-GridView-with-Empty-Message-and-Header-and-Footer-when-no-data-in-ASP.Net.aspx. I just edited this as follows. this is my gridview code:-
<asp:GridView ID="gvCustomers" runat="server" Width="550px" AutoGenerateColumns="false"
Font-Names="Arial" Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" HeaderStyle-BackColor="green"
AllowPaging="true" PageSize="10">
<Columns>
<asp:BoundField HeaderText="State Name" DataField="StateName" FooterText="Footer" />
<asp:BoundField HeaderText="Organizatio Name" DataField="OrganizatioName" FooterText="Footer" />
<asp:BoundField HeaderText="Partner Name" DataField="PartnerName" FooterText="Footer" />
</Columns>
<AlternatingRowStyle BackColor="#C2D69B" />
<EmptyDataTemplate>
<table cellspacing="0" rules="all" style="font-family: Arial;
font-size: 11pt; width: 550px; border-collapse: collapse;">
<tr style="background-color: Green;">
<th scope="col">
State Name
</th>
<th scope="col">
Organization Name
</th>
<th scope="col">
Partner Name
</th>
</tr>
<tr>
<td colspan = "3" align = "center">
No Data found.
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
and my code file code is as follows
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["contest"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind_Grid();
}
}
protected void Bind_Grid()
{
string strSql = "select * from mtblInformation";
SqlCommand com = new SqlCommand(strSql,con);
SqlDataAdapter sda = new SqlDataAdapter(com);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
gvCustomers.DataSource = dt;
gvCustomers.DataBind();
}
}
when in database table have records then gridview binds and its showing records, But when there is no record in DB , instead of showing msgs that "No Data found." gridview doesn't appear.
View 2 Replies
Similar Messages:
Mar 20, 2010
I have never work with a repeater and after a lot of research I got to the conclusion that this is the control I need to use for what I have to do. I need display data but I will need 2 headers and after some sort of amount of records the headers will repeat again. In this page you will find an example of what I'm trying to do http://ratings.fide.com/view_source.phtml?code=45276 I don't know if a repeater is the right control but i thin it is.
View 3 Replies
Feb 25, 2010
There is a gridview and I am binding some records to it. in my database there are 4 records but gridview always shows 3 records. Even I have given PageSize 10.
View 4 Replies
Jan 2, 2011
[Code]....
I have a question about datalist control. See I only need to display 12 records when the users are viewing in a small preview setting. How can I achieve that? I know I can get TOP 12 from the sql query, but is there a way I can modify in the datalist control itself? DataTable dt = new DataTable();
View 5 Replies
Mar 25, 2011
I wanted to have fixed headers in grid view. I came across multiple solutions but none worked with IE 8 and Chrome. One of the best solutions is following:
<style type="text/css">
<!--
.DataGridFixedHeader {background-color: white; position:relative; top:expression(this.offsetParent.scrollTop);}
-->
</style>
View 3 Replies
Jan 14, 2010
What is the best way to format a grid, (or any other control) in this format?
Header1 Header2
A B C D Header3 Header4 header5
row
row
row
row
row
Header3 Header4
row
eader5 Header6 header7 header8
row
row
row
footer data
is this format even possible?
View 3 Replies
Sep 14, 2010
I have a couple of Textboxes in a Gridview header, mainly used to search for items in the dataset. This works fine; however, on Post Back, the textboxes do not hold the entered text. The View State is enabled for these control items.
View 4 Replies
Nov 18, 2010
I have the following output from a SQL Datasource that I would like to separate into the Giant Sets...
Giant Set 1 Exercise 1 10 reps
Giant Set 1 Exercise 2 15 reps
Giant Set 1 Exercise 3 10 reps
Giant Set 2 Exercise 1 15 reps
Giant Set 2 Exercise 2 15 reps
Giant Set 2 Exercise 3 15 reps
So I want it to look like this...
Giant Set 1
Exercise 1 10 reps
Exercise 2 15 reps
Exercise 3 10 reps
Giant Set 2
Exercise 1 15 reps
Exercise 2 15 reps
Exercise 3 15 reps
Is this possible with a gridview?
View 2 Replies
Aug 5, 2010
I want scrollable gridview with fixed header. For that i create belw code
[Code]....
It works fine uptil page loads.I have functionality to delete rows from gridview.Once i click delete button from gridview the width of header columns get decreased then the width od data inside gridview.It means depending on the content of data the size gets variable.HOW to show data inside gridview irrespective of the content of data.
View 9 Replies
May 19, 2010
I would like to create a gridview which has as headers the last 12 months, which would need to change as time progresses... is it possible to do this?
View 24 Replies
Jun 25, 2010
Freezing Headers and Columns in a Gridview
[Code]....
View 8 Replies
Sep 17, 2010
I've been trying for the past few hours to add mutliple headers to my grid view but keep failing to get it to show. There's plenty of examples online that I found but can't seem to get the most simplest to work. Below is the code I've been using with no success. I even tried changing the "TableCell" o "TableHeaderCell" but still yields no headers as expected. Anyone know what I could be doing wrong?
[Code]....
View 16 Replies
Jan 25, 2010
I have been looking through endless webpages trying to get a handle on putting a scroll bar on a gridview, and fixing the headers . I have tried following a few examples and had a working demo on a test page, however when I placed the code in the main page on a FormView i have come up with the following error on this procedure
[Code]....
[Code]....
View 4 Replies
Jul 21, 2010
I just hit the same problem as described here: [URL] - GridView paging with ObjectDataSource. I see the column headers but no data, and I know for a fact my method returns a DataTable with data in it.
View 1 Replies
Oct 15, 2010
I have in my code a gridview that I redirect to excel, it works fine when I have data in the data set. waht I want is to show column headers when there is no data right now what i get is empty sheet.
View 7 Replies
Mar 3, 2011
i want to show the gridview headers alone if there is no data, how to do this?
View 6 Replies
Mar 16, 2011
i have a gridview which is populated from a stores proc using pivot tables. The column are created dynamically apart from a total column which is created as a template field. the gridview looks like below:
CPW
EE
Foh
H3G
IND
O2
ORG
P4U
T-M
TSC
VIR
VOD
Total
Stores Visited
70
0
0
12
0
16
18
7
11
1
2
8
145
i need to add a hyperlink to each gridview cell and when that cell is clicked pass the header text through the querystring to another page. I can access the cells value ok and pass that through but i cannot seem to access the cells column header text. when i response.write out a count of the gridview.columns it brings back 2 which is the template fields but not the dynamic fields i have tried this on the rowdatbound, rowcreated, page_load and page_unload. the count should be 12 its like it cannot find the dynamic columns at all. ?
here is my code for populating the gridview
[Code]....
and here is my gridview:
[Code]....
i am also moving the total column in this code
[Code]....
and calculating my total in this code and adding my link to the total colum (which works fine)
[Code]....
now i just need to somehow add a link to the other cells and somehow get the value of the header text for that cell clicked.
View 2 Replies
Dec 17, 2010
I have four column in which im getting three column value based on first column the result will be shown from database
[Code]....
View 8 Replies
Apr 22, 2010
I'm at an internship fixing this internal system in ASP.NET and C# using VS2008, and I have a gridview that displays purchases, rebate earned, and account number. When I load the page, only the first row of data shows up, and it's always the same values. I sent the output to a label, and my distributor ID and sales amount is the same for the 98 rows. We use MySQL for our database.
Here is my code
[Code]....
[Code]....
distID is always 1224, sales is always 1476.29
I feel like distID should also be in a foreach loop, but I don't how I would do it.
View 18 Replies
Oct 9, 2012
I have boundfiled column inside gridview and made the column as invisible by setting visible="false".
But while exporting the gridview to excel I am getting the Header text alone exported. Wherever the column's visibility is set to false the header text should not be exported. After binding the gridview I have set the column's visiblity to false so it won't export the column values.
The problem is to stop exporting the header text to excel. Let's say column index is 10
public class GridViewExportUtil
{
public static void Export(string fileName, GridView gv)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader(
"content-disposition", string.Format("attachment; filename={0}", fileName));
[CODE]...
View 1 Replies
Jan 25, 2012
I recently applied a javascript code from article "Dynamically freeze ASP.net Gridview header using Javascript" found here, ASP Snippets Article, to my page. The javascript works great, but somehow, it's overriding my CSS code for the headers. When I refresh the page, I can see the headers with my CSS in place for just a fraction of a second before it is replaced with generic styling. I am not a javascript person, so really can't troubleshoot the problem. I have a style sheet with the following code.
.dGrid {
width: 983px;
background-color: #ffffff;
[Code]......
View 1 Replies
May 7, 2015
Refer here: [URL] ....
What If i have many fields to be included in the gridview, so in that case I need HORIZONTAL SCROLL BAR. But I can't fixed the headers...
View 1 Replies
Feb 21, 2013
I used the link below [URL] .....
I have nearly 25 columns in my Gridview so when i apply the scrollable gridview the header does not align with template field.
View 1 Replies
Nov 30, 2013
I try to make a combination of 2 of your articles
[URL]
It works but the column header width's are not matching the data columns.
When i take out the nested gridview it works fine.
Here's my code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$("[src*=plus]").live("click", function () {
$(this).closest("tr").after("<tr><td></td><td colspan = '999'>" + $(this).next().html() + "</td></tr>")
$(this).attr("src", "images/minus.png");
[code]....
View 1 Replies
Jan 16, 2014
Scrollable GridView with Fixed Headers inside ASP.Net UpdatePanel using jQuery Plugin. I have one more question in that. How to adjust the width of the columns headers because for some of my gridviews the headers not showing the proper format. in the gridview I gave HorizontalAlign="Left" and in the columns I gave
<asp:BoundField DataField="XXX" HeaderText="XXX" ItemStyle-Width="150px" HeaderStyle-HorizontalAlign="Left" />
It's not showing in the correct fomart. header is coming to the left side and data is coming to the right side...
View 1 Replies