We help IT Professionals succeed at work.

How do I locate the source of a dropdown in C#

darrennelson
darrennelson asked
on
C# newb - I inherited an app and I need to modify the contents of a dropdown list.  The code behind the dropdown is:

<asp:DropDownList ID="ddlStoreID" runat="server" Width="140px"></asp:DropDownList>

i searched various files and found a connection string, oStoreID, but can't find what it's connecting to.

////show store id in drop downlist
            List<string> oStoreID = new List<string>();

There's also a ConnectStringDB.cs file that contains:

using System;
using System.Collections.Generic;
using System.Text;

namespace ClassLibrary
{
    public class ConnectStringDB
    {
        public static string connectionString
        {
            get
            {
                return System.Web.Configuration.WebConfigurationManager.ConnectionStrings["helpDeskConnection"].ConnectionString;
            }
        }
    }

}

any help is appreciated.
Comment
Watch Question

SILVER EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Look in a file named web.config and find the section entitled "connectionStrings". You should see an entry named "helpDeskConnection". Within the "connectionString" attribute's value you should see the database and instance names.

Author

Commented:
My brain didn't catch up with my fingers and I forgot to mention that part.  It's pointing to our MS SQL db.  There are 17 tables set up for this app.  Five of the tables have a storeID field, but there is no table specifically or obviously just for holding storeIDs.  Example, one table name is helpdesk_issues.  In this table the storeID is tied to issues opened by that store.  All tables that have storeID make use of the storeID in this manner.

Is it possible the dropdown list is hardcoded in one of the files?  Is there any easy way to locate all queries in the code?
SILVER EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Are there any lines in the code behind like:

ddlStoreID.DataBind();

Open in new window

Author

Commented:
yup, this is the ELSE statement after the IF I pasted in above:

else //for ITSupport
            {
                //oStoreID = this.GetStoreID();
                oStoreID = ClassLibrary.IssuesLib.GetStoresCO();
                this.ddlStoreID.DataSource = oStoreID;
                this.ddlStoreID.DataBind();
            }
SILVER EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
Navigate to the function GetStoresCO's definition. See if you have a SQL statement there. If not, you'll have to see what other functions are called within GetStoresCO and inspect those functions as well.

Author

Commented:
thank you very much.  It was actually querying the storemaster table we use for maintaining store info.  I was confused because there were closed stores showing up in the app, but after looking at the database, these closed stores had never been flagged as closed.
SILVER EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Awesome. Glad you tracked it down  = )

Explore More ContentExplore courses, solutions, and other research materials related to this topic.