placeholder showing cs0103

تبليغ
سؤال

يرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.

تبليغ
‎إلغاء

My place holder in the C# part is coming up with a cs0103 and i cant figure out why. im trying to put data into a table in the html portion and was using a place holder. but it seems to be having an issue with my place holder id placeholder1. can any one see the issue im running into

Here Is my HTML

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”Home.aspx.cs” Inherits=”AdventureWorks.WebForm1″ %>

<!DOCTYPE html>

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Adventure Works Home</title>
<link rel=”stylesheet” href=”StyleSheet.css”/>
</head>
<body>
<img class=”banner” src=”Images/AdvWorksBanner.png” alt=”Adventure Works”/>
<div class=”title”><img class=”imgleft” src=”Images/trainer_red.png” /><img class=”imgright” src=”Images/trainer_red.png” />Products Page</div>
<div class=”nav”>
<button type=”button” onclick=”location.href=’home.aspx'” class=”button”>Home</button>
<button type=”button” onclick=”location.href=’about.aspx'” class=”button”>About</button>
<button type=”button” onclick=”location.href=’products.aspx'” class=”button”>Products</button>
<button type=”button” onclick=”location.href=’Login.aspx'” class=”button”>Login</button>
</div>
<div>
<asp:PlaceHolder ID = “PlaceHolder1” runat =”server”/>
</div>

</body>
</html>

Here is the C#

namespace AdventureWorks
{

public partial class Products : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{

if (!this.IsPostBack)
{
//Populating a DataTable from database.
DataTable dt = this.GetData();

//Building an HTML string.
StringBuilder html = new StringBuilder();

//Table start.
html.Append(“<table border = ‘1’>”);

//Building the Header row.
html.Append(“<tr>”);
foreach (DataColumn column in dt.Columns)
{
html.Append(“<th>”);
html.Append(column.ColumnName);
html.Append(“</th>”);
}
html.Append(“</tr>”);

//Building the Data rows.
foreach (DataRow row in dt.Rows)
{
html.Append(“<tr>”);
foreach (DataColumn column in dt.Columns)
{
html.Append(“<td>”);
html.Append(row[column.ColumnName]);
html.Append(“</td>”);
}
html.Append(“</tr>”);
}

//Table end.
html.Append(“</table>”);

//Append the HTML string to Placeholder.
PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() });
}
}
private DataTable GetData()
{
using (var connection = Functions.AdventureWorks())
{
connection.Open();
using (SqlCommand cmd = new SqlCommand(“SELECT Name, ListPrice FROM Production.Product where ListPrice Is Not Null and ListPrice != 0;”))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = connection;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}

}
}
}
}

‫أضف إجابة

تصفح
تصفح

مجهول يجيب