DataSet using a repeater?

Im having trouble with displaying the information with repeater, this is done with 2 projects, company and supplier. i used web service to get the information from supplier to company.

Error: the name 'dae does not exist in the current context' (.cs page at the company side)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PawsPawsMock.BLL;
using System.Data;
using System.Data.SqlClient;

namespace PawsPawsMock
{
    public partial class AdminECatalog : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindEventRepeater();
            }
        }
        private void BindEventRepeater()
        {
            BllCompEventCatalog eve = new BllCompEventCatalog();
            DataSet ds = new DataSet(); 
                DataTable dte = new DataTable();
                dae.Fill(dte);
                rptrEvents.DataSource = dte;
                rptrEvents.DataBind();
        }
    }
}

Open in new window

the aspx page(source):
 <asp:Repeater ID="rptrEvents" runat="server">
            <ItemTemplate>
                <div class="col-sm-3 col-md-3">
                    <div class="thumbnail">
                        <!--Add image here--->
                        <div class="caption">
                             <div class="proName"><%#Eval("EName") %></div>
                            <div class="proPrice"><span class="proOgPrice"><%#Eval("EPrice") %></span> <%#Eval("ESelName") %><span class="proPriceDiscount">(201 Off)</span></div>
                        </div>
                    </div>
                </div>
            </ItemTemplate>
        </asp:Repeater>

Open in new window

JayAsked:
Who is Participating?
 
Dirk StraussConnect With a Mentor Senior Full Stack DeveloperCommented:
Your code should look something like this:

private void BindEventRepeater()
{
    string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    using (SqlConnection con = new SqlConnection(constr))
    {
        using (SqlCommand cmd = new SqlCommand("SELECT * FROM EventsTable", con)) // SELECT is Pseudo, replace with actual query
        {
            using (SqlDataAdapter dae = new SqlDataAdapter(cmd))
            {
                DataTable dt = new DataTable();
                dae.Fill(dt);
                rptrEvents.DataSource = dt;
                rptrEvents.DataBind();
            }
        }
    }
}

Open in new window

As a side note, this is really basic code. I would not recommend using inline SQL as per the above example. The example above is to illustrate the use of the SqlDataAdapter that you are missing in your code.
Note: Above code is also untested.
0
 
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
Just as the error indicates, you have not defined what dae is in your code. Best guess is it should be a data adapter.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.