|
-
Aug 15th, 2011, 12:55 AM
#1
Thread Starter
Frenzied Member
gridview is disappearing
Here is my aspx page:
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="GridViewDisappearing._Default" %>
<%@ Register Assembly="GridViewDisappearing" Namespace="GridViewDisappearing" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Product" HeaderText="Product" SortExpression="Product" />
<asp:BoundField DataField="Warehouse" HeaderText="Warehouse" SortExpression="Warehouse" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SampleDBConnectionString %>"
SelectCommand="SELECT [ID], [Product], [Warehouse], [Quantity] FROM [Inventory]">
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
And here is the code behind:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace GridViewDisappearing
{
public partial class _Default : MyPage1
{
protected void Page_Init(object sender, EventArgs e)
{
int x = GridView1.Rows.Count;
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
The first time the page is requested, it displays the gridview with the data. But when I click on the button, the gridview disappears (and only the button shows up). When I comment out the code:
int x = GridView1.Rows.Count;
in the Page_Init(), the gridview does NOT disappear. Why is that one line of code causing it to disappear?
Last edited by benmartin101; Aug 15th, 2011 at 12:58 AM.
-
Aug 16th, 2011, 11:24 PM
#2
Re: gridview is disappearing
By looking at the code I can say that the code should work fine. Is this the only code you have ?
Please mark you thread resolved using the Thread Tools as shown
-
Aug 31st, 2011, 01:57 AM
#3
Thread Starter
Frenzied Member
Re: gridview is disappearing
 Originally Posted by danasegarane
By looking at the code I can say that the code should work fine. Is this the only code you have ?
Have you tried running that code? Because I'm curious if you can get it to work "normal", then I'd know that it may have something to do with a configuration setting on my vs2008 express(as oppose to the code).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|