コード例 #1
0
 private void LoadType()
 {
     try
     {
         List <CompType> result = new List <CompType> {
             new CompType {
                 id = 0, name = ""
             }
         };
         DDType.DataTextField  = "name";
         DDType.DataValueField = "id";
         DDType.DataSource     = result;
         using (InhToDoListDataContext context = new InhToDoListDataContext())
         {
             result.AddRange(context.mst_types
                             .Where(x => x.mst_status == 'A')
                             .Select(x => new CompType
             {
                 id   = x.mst_id,
                 name = x.mst_tname
             }).ToList());
         }
         DDType.DataBind();
     }
     catch (Exception ex)
     {
     }
     //var objmstid = (from tid in dbc.mst_types select new { id = tid.mst_id, name = tid.mst_tname }).ToList();
     //DDType.DataTextField = "name";
     //DDType.DataValueField = "id";
     //DDType.DataSource = objmstid;
     //DDType.DataBind();
     //DDType.Items.Insert(0, String.Empty);
     //DDType.SelectedIndex = 0;
 }
コード例 #2
0
        protected void llenarDrop()
        {
            DataTable datos = ApplicationClass.GetApplicationType();

            datos.DefaultView.Sort = "Apl_Tip_Descripcion";
            DDType.DataSource      = datos;
            DDType.DataTextField   = "Apl_Tip_Descripcion";
            DDType.DataValueField  = "Apl_Tip_Id";
            DDType.DataBind();

            DDType2.DataSource     = datos;
            DDType2.DataTextField  = "Apl_Tip_Descripcion";
            DDType2.DataValueField = "Apl_Tip_Id";
            DDType2.DataBind();
        }
コード例 #3
0
    protected void DDFill()
    {
        DataTable     dt1, dt2, dt3, dt4;
        SqlConnection con = new SqlConnection("DATA SOURCE=GOVINDSUPERCOMP;INITIAL CATALOG=Tutor;Integrated Security=True;");
        SqlCommand    com = new SqlCommand();

        try
        {
            con.Open();
            string sqlStatement;
            sqlStatement = "SELECT DISTINCT [typename] FROM [typeofTutor]";
            SqlCommand     sqlCmd = new SqlCommand(sqlStatement, con);
            SqlDataAdapter sqlDa  = new SqlDataAdapter(sqlCmd);
            dt1 = new DataTable();
            sqlDa.Fill(dt1);
            if (dt1.Rows.Count > 0)
            {
                DDType.DataSource = dt1;
                DDType.DataBind();
            }

            sqlStatement = "SELECT DISTINCT [subname] FROM [subject]";
            sqlCmd       = new SqlCommand(sqlStatement, con);
            sqlDa        = new SqlDataAdapter(sqlCmd);
            dt3          = new DataTable();
            sqlDa.Fill(dt3);
            if (dt3.Rows.Count > 0)
            {
                DDsub.DataSource = dt3;
                DDsub.DataBind();
            }

            sqlStatement = "SELECT DISTINCT [stdname] FROM [standard]";
            sqlCmd       = new SqlCommand(sqlStatement, con);
            sqlDa        = new SqlDataAdapter(sqlCmd);
            dt2          = new DataTable();
            sqlDa.Fill(dt2);
            if (dt2.Rows.Count > 0)
            {
                DDstd.DataSource = dt2;
                DDstd.DataBind();
            }
            sqlStatement = "SELECT DISTINCT [locname] FROM [location]";
            sqlCmd       = new SqlCommand(sqlStatement, con);
            dt4          = new DataTable();
            sqlDa        = new SqlDataAdapter(sqlCmd);
            sqlDa.Fill(dt4);
            if (dt4.Rows.Count > 0)
            {
                DDLoc.DataSource = dt4;
                DDLoc.DataBind();
            }
        }
        catch (System.Data.SqlClient.SqlException ex)
        {
            string msg = "No Data Found To display in the DropDown List";
            msg += ex.Message;
            throw new Exception(msg);
        }
        finally
        {
            con.Close();
        }
    }