Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 802923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:40:34+00:00 2026-05-14T23:40:34+00:00

I am developing a C# VS 2008 / SQL Server 2008 website, but now

  • 0

I am developing a C# VS 2008 / SQL Server 2008 website, but now I cannot display the Gridview containing my table. I included the Default.aspx and aspx.cs files below. What do I need to do to fix this? I am not getting any errors now; just that this grid does not show up. Thanks!

ASPX file:

<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs"
    Inherits="_Default" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <asp:Panel runat="server" ID="AuthenticatedMessagePanel">
        <asp:Label runat="server" ID="WelcomeBackMessage"></asp:Label>
        <table>
            <tr>
                <td>
                    <asp:Label ID="tableLabel" runat="server" Font-Bold="True" Text="Select target table:"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="inputLabel" runat="server" Font-Bold="True" Text="Select input file:"></asp:Label>
                </td>
            </tr>
            <tr>
                <td valign="top">
                    <asp:Label ID="feedbackLabel" runat="server"></asp:Label>
                    <asp:SqlDataSource ID="SelectTables" runat="server" ConnectionString="<%$ ConnectionStrings:AdventureWorks3_SelectTables %>"
                        SelectCommand="getTableNames" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:QueryStringParameter DefaultValue="Person" Name="SchemaName" QueryStringField="SchemaName"
                                Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:GridView ID="GridView1" DataSourceID="SelectTables" runat="server" Style="width: 400px;"
                        CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
                        AutoGenerateSelectButton="True" DataKeyNames="TABLE_NAME">
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <Columns>
                            <asp:BoundField HeaderText="TABLE_NAME" DataField="TABLE_NAME" />
                        </Columns>
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <EditRowStyle BackColor="#999999" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    </asp:GridView>
                </td>
                <td valign="top">
                    <input id="uploadFile" type="file" size="26" runat="server" name="uploadFile" title="UploadFile"
                        class="greybar" enableviewstate="True" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel runat="Server" ID="AnonymousMessagePanel">
        <asp:HyperLink runat="server" ID="lnkLogin" Text="Log In" NavigateUrl="~/Login.aspx">
        </asp:HyperLink>
    </asp:Panel>
</asp:Content>

ASPX.CS file:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.IO;
using System.Drawing;
using System.ComponentModel;
using System.Data.SqlClient;
using ADONET_namespace;
using System.Security.Principal;
//using System.Windows;

public partial class _Default : System.Web.UI.Page

//namespace AddFileToSQL
{
        //protected System.Web.UI.HtmlControls.HtmlInputFile uploadFile;
        protected System.Web.UI.HtmlControls.HtmlInputButton btnOWrite;
        protected System.Web.UI.HtmlControls.HtmlInputButton btnAppend;
        protected System.Web.UI.WebControls.Label Label1;
        protected static string inputfile = "";
        public static string targettable;
        public static string selection;

        // Number of controls added to view state
        protected int default_NumberOfControls
        {
            get
            {
                if (ViewState["default_NumberOfControls"] != null)
                {
                    return (int)ViewState["default_NumberOfControls"];
                }
                else
                {
                    return 0;
                }
            }
            set
            {
                ViewState["default_NumberOfControls"] = value;
            }
        }

        protected void uploadFile_onclick(object sender, EventArgs e)
        {
        }

        protected void Load_GridData()
        {
            //GridView1.DataSource = ADONET_methods.DisplaySchemaTables();
            //GridView1.DataBind();
        }

        protected void btnOWrite_Click(object sender, EventArgs e)
        {
            if (uploadFile.PostedFile.ContentLength > 0)
            {
                feedbackLabel.Text = "You do not have sufficient access to overwrite table records.";
            }
            else
            {
                feedbackLabel.Text = "This file does not contain any data.";
            }
        }

        protected void btnAppend_Click(object sender, EventArgs e)
        {
            string fullpath = Page.Request.PhysicalApplicationPath;

            string path = uploadFile.PostedFile.FileName;

            if (File.Exists(path))
            {
                // Create a file to write to.
                try
                {
                    StreamReader sr = new StreamReader(path);
                    string s = "";
                    while (sr.Peek() > 0)
                        s = sr.ReadLine();
                    sr.Close();
                }
                catch (IOException exc)
                {
                    Console.WriteLine(exc.Message + "Cannot open file.");
                    return;
                }
            }

            if (uploadFile.PostedFile.ContentLength > 0)
            {

                inputfile = System.IO.File.ReadAllText(path);
                Session["Message"] = inputfile;
                Response.Redirect("DataMatch.aspx");
            }
            else
            {
                feedbackLabel.Text = "This file does not contain any data.";
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                WelcomeBackMessage.Text = "Welcome back, " + User.Identity.Name + "!";

                // Reference the CustomPrincipal / CustomIdentity
                CustomIdentity ident = User.Identity as CustomIdentity;
                if (ident != null)
                    WelcomeBackMessage.Text += string.Format(" You are the {0} of {1}.", ident.Title, ident.CompanyName);

                AuthenticatedMessagePanel.Visible = true;
                AnonymousMessagePanel.Visible = false;
                if (!Page.IsPostBack)
                {
                    Load_GridData();
                }                                
            }
            else
            {
                AuthenticatedMessagePanel.Visible = false;
                AnonymousMessagePanel.Visible = true;
            }
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = GridView1.SelectedRow;
            targettable = row.Cells[2].Text;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:40:35+00:00Added an answer on May 14, 2026 at 11:40 pm

    Are you sure you have data being returned? You could put in

     <EmptyDataTemplate>
           <span>No records found.</span>
      </EmptyDataTemplate>
    

    Which would give you a visible element if there is no data to fill the grid with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 487k
  • Answers 487k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to replace the & inside the attribute value… May 16, 2026 at 8:12 am
  • Editorial Team
    Editorial Team added an answer You will not be able to do it with ASP.net… May 16, 2026 at 8:11 am
  • Editorial Team
    Editorial Team added an answer I spoke to Brad Wilson on Twitter and he indicated… May 16, 2026 at 8:11 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.