コード例 #1
0
        public void bindrow()
        {
            using (SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["con"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("SELECT [Event_Name] FROM [Event1];"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = conn;
                    conn.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataSet        ds = new DataSet();
                    da.Fill(ds);
                    EventsList.DataTextField = ds.Tables[0].Columns["Event_Name"].ToString();
                    EventsList.DataSource    = ds.Tables[0];
                    EventsList.DataBind();

                    conn.Close();
                }
            }
            EventsList.Items.Insert(0, new ListItem("Select CLUB NAME", "0"));
        }