Building the BLL layer and DAL for a user control dropdownlist

I have the following:

namespace KORE.SIDWebClient.BLL
{
    public class LookupFieldTicketAgentFollowup
    {
         private DataSet _lookupdata;

        #region "constructors"

        public LookupFieldTicketAgentFollowup()
        {
            this._lookupdata = LookupFieldTicketAgentFollowupData.getLookupFieldTicketAgentFollowupData();
        }

        #endregion



        #region "methods"

        public ListItem[] getLookupListItemGroup(string keyField, string valueField)
        {
            ListItem[] list = new ListItem[this._lookupdata.Tables[0].Rows.Count];

            int i = 0;

            foreach (DataRow dr in this._lookupdata.Tables[0].Rows)
            {
                list[i++] = new ListItem(dr[keyField].ToString(), dr[valueField].ToString());
            }

            return list;
        }

        #endregion
    }
}

and then I have the DAL
namespace KORE.SIDWebClient.DAL
{
    public partial class LookupFieldTicketAgentFollowupData
    {
        public static DataSet getLookupFieldTicketAgentFollowupData()
        {
            Database db = DatabaseFactory.CreateDatabase();
            string sql = "sprLookupFieldTicketAssignedTo";

            DbCommand cmd = db.GetStoredProcCommand(sql);
            DataSet fieldTicketAgentFollowupDataSet = db.ExecuteDataSet(cmd);

            return fieldTicketAgentFollowupDataSet;
        }
}
===========================================

I am building a web control for the forlowing dropdow
 protected void Page_Load(object sender, EventArgs e)
        {
            LookupFieldTicketAgentFollowupDropDown.DataSource = BLL.LookupFieldTicketAgentFollowup;
            // Needed to bind the data bound controls to the data source
            LookupFieldTicketAgentFollowupDropDown.DataBind();
        }

But I must modify my BLL to return a dataset.
The DAL returns a dataset.

So how should I approach this.
I appreciate any help.
mathieu_cuprykAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ppittleCommented:
Scott Mitchell has a phenomenal set of tutorials on databinding available at http://www.asp.net/learn/data-access/.  I highly recommend you take a look at atleast the first 3, as they provide a great introduction into asp.net's databiding features.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ppittleCommented:
For a quick answer, for your scenario, your BLL doesn't appear to be doing very much.  You're BLL could simply wrap the DAL method.  Or you could go 2-tier, and have your code behind call the DAL directly:

public class LookupFieldTicketAgentFollowup
 {
public DataSet getLookupFieldTicketAgentFollowupData()
{
return LookupFieldTicketAgentFollowupData.getLookupFieldTicketAgentFollowupData();
}
}

protected void Page_Load(object sender, EventArgs e)
        {

LookupFieldTicketAgentFollowup bll = new LookupFieldTicketAgentFollowup();
            LookupFieldTicketAgentFollowupDropDown.DataSource = bll .getLookupFieldTicketAgentFollowupData;
            // Needed to bind the data bound controls to the data source
            LookupFieldTicketAgentFollowupDropDown.DataBind();
        }


0
mathieu_cuprykAuthor Commented:
ticket.AgentFollowup = uxLookupFieldTicketAgentFolowup1.FindControl(D;

How do I assign the value.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="uxLookupFieldTicketAgentFollowup.ascx.cs" Inherits="KORE.SIDWebClient.UI.Controls.uxLookupFieldTicketAgentFollowup" %>


<asp:DropDownList ID="LookupFieldTicketAgentFollowupDropDown" AppendDataBoundItems="true" runat="server">
<asp:ListItem Value=""></asp:ListItem>
</asp:DropDownList>
0
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

mathieu_cuprykAuthor Commented:
DO I have to put datasourceID and datatextfeld?
 
0
ppittleCommented:
yes, you'll want to set the DataTextField property you can set which field in your dataset will be displayed on the GUI.  You wont need to set the DataSourceID property, because you're setting the DataSource property in the codebehind.  Setting both will generate an exception.
0
mathieu_cuprykAuthor Commented:
This is what I am doing. Then on the second post back it fails on the bind.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="uxLookupFieldTicketContactMethod.ascx.cs" Inherits="KORE.SIDWebClient.UI.Controls.uxLookupFieldTicketContactMethod" %>


<asp:DropDownList ID="LookupFieldTicketContactMethodDropDown" runat="server">
</asp:DropDownList>
<br />
<asp:RequiredFieldValidator id="CVLookupFieldTicketContactMethodDropDown"
        Text="(Required)"
        InitialValue=""
        ControlToValidate="LookupFieldTicketContactMethodDropDown"
        Runat="server" />

===================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KORE.SIDWebClient.BLL;
using System.ComponentModel;

namespace KORE.SIDWebClient.UI.Controls
{
    public partial class uxLookupFieldTicketContactMethod : System.Web.UI.UserControl
    {
        private static readonly LookupFieldTicketContactMethod _lookup = new LookupFieldTicketContactMethod();
       
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LookupFieldTicketContactMethodDropDown.DataSource = _lookup.getLookupFieldTicketContactMethodData();
                LookupFieldTicketContactMethodDropDown.DataTextField = "ContactMethod";
                LookupFieldTicketContactMethodDropDown.DataValueField = "ID";
                LookupFieldTicketContactMethodDropDown.DataBind();
                // Add a blank entry as the first item in the list
                //LookupFieldTicketContactMethodDropDown.Items.Insert(0, new ListItem("", "0"));
             
            }
        }

        public int SelectedIndex
        {
            get
            {
                //return this.LookupFieldTicketContactMethodDropDown.SelectedIndex;
                return Convert.ToInt32(ViewState["SelectedIndex"]);

            }
            set
            {
                ViewState["SelectedIndex"] = value;
                //this.LookupFieldTicketContactMethodDropDown.SelectedIndex = value;
            }
        }

        public string SelectedValue
        {
            get
            {
                return Convert.ToString(ViewState["SelectedValue"]);
                //return this.LookupFieldTicketContactMethodDropDown.SelectedValue;
            }
            set
            {
                ViewState["SelectedValue"] = value.ToString();
               // this.LookupFieldTicketContactMethodDropDown.SelectedValue = value;
            }
        }

        public bool AutoPostBack
        {
            get { return Convert.ToBoolean(ViewState["AutoPostBack"]); }
            set { ViewState["AutoPostBack"] = value; }

        }

       

       

       

    }
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.