0

Hey fellas,

I have a problem with my current code. I have a checklist that i want certain items to be selected bases of a sql query. here is the code:

public void PopulateCheckList(int Program_Id)
        {
            SqlDataReader myReader = null;
            String appConnectionString = "Data Source=csdb-wc-1p;DataBase=oparch_metrics_v2;User ID=ops_metrics_admin;Pwd=M3tr!c$@dm!n";
            SqlConnection myConnection = new SqlConnection(appConnectionString);
            String result;
            try
            {
                myConnection.Open();
                string sqlCommand = "Select AppID From CET_ScorecardProgramApplicationMapping WHERE Program_Id = @Pogram_Id";
                SqlCommand mycommand = new SqlCommand(sqlCommand, myConnection);
                mycommand.CommandType = CommandType.StoredProcedure;
                mycommand.Parameters.Add(new SqlParameter("@Program_Id", Program_Id));
                 
                myReader = mycommand.ExecuteReader();

                ListItem first = new ListItem();
   
                ddlContacts.Items.Add(first);

                while (myReader.Read())
                {
                    if()
                    
                    
                    applicationCheckList.Item[i].Selected =  true ;
                }
            }
            catch (SqlException ex)
            {
                result = ex.ToString();
            }
            finally
            {
                if (myConnection != null)
                {
                    myConnection.Close();
                }
                if (myReader != null)
                {
                    myReader.Close();
                }
            }
        }

im not sure what to put in the while(myRead.Read()) loop

if you guys could help me i would be very grateful

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by jaycastr
0

Something like this i think?

while (myReader.Read())
                {
                    foreach (ListItem item in applicationCheckList.Items)
                    {
                        if (applicationCheckList.Items.Value == myReader.GetString(0))
                         {
                             applicationCheckList.Items(0).selected = true;
                         }
                    }
                }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.