Forms Data Controls :: How To Show The Gridview Headers Alone If There Is No Data
Mar 3, 2011i want to show the gridview headers alone if there is no data, how to do this?
View 6 Repliesi want to show the gridview headers alone if there is no data, how to do this?
View 6 RepliesI 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 RepliesI 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 RepliesI 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 RepliesI 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>
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?
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 RepliesI 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?
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.
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.
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 RepliesFreezing Headers and Columns in a Gridview
[Code]....
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]....
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]....
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.
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]...
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]......
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...
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.
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]....
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...
In article [URL] .... I want to change the header Styling. Is it possible to change?? If yes then how?
Also, i want to use label inside header (to write heading).
I have a customized gridvew i.e. grvResult. There is a textbox and a InsertButton in the footer.
If there is a data populated into gridview it is showing GridView footer and inserting data but if there is no data in gridview then its footer also not visible.
I have tried in two ways to make footer visible but it is showing following error:
Object reference not set to an instance of an object.
Tried ways:
[Code]....
[Code]....
I am using an ADO Entity Model for my ms-sql database.
My database has a Resellers table which has ResellerID (primary key, int) and Name columns along with other data.
I also have an Orders table which contains OrderID (primary key, int), OrderDate, ResellerID (foreign key to Resellers.ReselerID).
If I just do a query like:
[Code]....
I am able to reference order.Reseller.Name just fine with no problems.
However I have an EntityDataSource on my page as follows:
[Code]....
Notice the Include="Reseller" attribute in the datasource... I also have a GridView tied to that datasource as follows: I cut some of it off for breavity:
[Code]....
Now what I have listed above will run with no errors, but what I want to do is replace the column that displays "ResellerID" with the equivilant to order.Reseller.Name. In other words I want my grid to display the reseller's name rather than the numeric ID.
I have tried to change the DataField to "Reseller.Name" but that will generate the following error:
A field or property with the name 'Reseller.Name' was not found on the selected data source.
Is there anyway to do this without me writing a custom select statement in my code behind?
What I want to do is to replace number with a name. So if in the Month Column it receives five "1" it changes those 5 "1" to JANUARY.
Is it possible? This is because unfortunately I can only arrange my months by number and not by their name, this because of my queries and tables format, so, I thought maybe I can tell the gridview to change the month number to their relative month name.