Hi Everyone,
I am trying to display data from a table on to a page by using a label and my label is not being recognized. The code for my aspx page is as follows:
Results.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="Results.aspx.cs" Inherits="Members_Results" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<link href="Styles/Content1.css" rel="stylesheet" />
<div id="content">
<span style="font-family: Arial, Helvetica, sans-serif; font-size: large">Welcome to Genealogy-Biography.com,
You are Logged In as : </span>
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:LoginStatus ID="LoginStatus1" runat="server" />
</AnonymousTemplate>
<LoggedInTemplate>
<asp:LoginName ID="LoginName1" runat="server" Font-Bold="true" />
<asp:LoginStatus ID="LoginStatus2" runat="server" />
</LoggedInTemplate>
</asp:LoginView>
<br />
<br />
<div style="font-family: Arial, Helvetica, sans-serif; font-size: large; text-transform: uppercase"><b><center>Personal Membership Family Tree Builder Results Page</center></b></div>
<div style="text-align: justify">
<br />
Welcome to the personal membership family tree builder results page stage 1, please check all information to make sure that it is as complete as possible in order to take advantage of your free personal membership. Remember that all information is shared with other members of Genealogy-Biography.com so they can complete their family trees. If you need to make changes, then press edit and you will be brought to a page so you can edit the information. If not then just press the Update button below to continue. Please check all information below:<br />
<br />
</div>
<asp:Label ID="labelname1" runat="server" Text="Label">FamilyName:</asp:Label>
<br />
<br />
</div>
<div id="ad" style="font-size: x-small"><strong>Please place your Advertisement</strong></div>
</asp:Content>
and the code behind it is, Results.aspx.cs:
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.Data.SqlClient;
namespace Displaying_Data_From_Db_to_Label
{
public partial class Members_Results : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["GenealogyConnectionString1"].ConnectionString;
string str;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select * from aspnet_SearchGen";
com = new SqlCommand(str, con);
SqlDataReader reader = com.ExecuteReader();
reader.Read();
labelname1.Text = reader["FamilyName"].ToString();
reader.Close();
con.Close();
}
}
}
I am getting a compilation error, which is as follows:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
Source Error:
|
Line 14: namespace Displaying_Data_From_Db_to_Label
Line 15: {
Line 16: public partial class Members_Results : System.Web.UI.Page Line 17: {
Line 18: string strConnString = ConfigurationManager.ConnectionStrings["GenealogyConnectionString1"].ConnectionString;
|
Source File: c:\Genealogy\Members\Results.aspx.cs Line: 16
also my labelname.Text is not being recognized even though it is declaired a label on the results.aspx page. Do you have any ideas?
Thanks
ASW