explaın: I cannot return the database data with the while oledbdatareader or sqldatareader in the web designer form and html table in Visual Studio 2015 the editor say dr1 variable get a the name dr1 does not exıst context say error and I'm trying to make the code look like a list like MVC.
I don't want to use placeholder dataview buildingstring datalist etc.
I couldn't manage to create a loop on the classic html table web designer side.
In short, the loop should be on the web designer form side.
I couldn't find any examples in movies or examples on the internet and how should the behind and web design side of my code be?
I would appreciate it if you could help me.
For example, in all codes, behind side always has buildingstring dataview placeholder etc.
Kind regards
namespace JOIN_PROJEM
{
public partial class WebForm2 : System.Web.UI.Page
{
public IEnumerable<IDataRecord> ListUrunlers()
{
OleDbConnection connection = new OleDbConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
OleDbCommand command = new OleDbCommand("select * from country", connection);
connection.Open();
OleDbDataReader dr = command.ExecuteReader();
while (dr.Read())
{
yield return dr;
}
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="JOIN_PROJEM.WebForm2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<% foreach (idatarecord record in ListUrunlers()) { %>
<tr>
<td> Product Name:</td>
<td> <%= record["urunadi"] %> </td>
<td> <%= record["productlinki"] %> </td>
</tr>
<% } %>
</table>
</div>
</form>
</body>
</html>
idatarecord does not appear. There are many elements starting with idata in the library, but this one does not exist.
How can I add it? It says add a missing reference to it.