using System; using System.ComponentModel; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.Serialization; using Microsoft.SharePoint; using Microsoft.SharePoint.Utilities; using Microsoft.SharePoint.WebPartPages; using Microsoft.SharePoint.WebControls; using System.Collections; using System.IO; using System.Data.SqlClient; using System.Data.SqlTypes; using System.Data.OleDb; namespace WebPartLibrary1 { public class WebPart1 : Microsoft.SharePoint.WebPartPages.WebPart { // Def des chps qui seront utilisés DropDownList DDLTest = new DropDownList(); private void ConnectSQL() { string strConnexion = "workstation id=SPH-EC98U2MN78X;packet size=4096;integrated security=SSPI;data source=SPH-EC98U2MN78X;persist security info=False;initial catalog=DPSP"; string strRequete = "SELECT ProfessionnelsDeSante FROM ListeTP;"; // DataSet oDataSet = new DataSet("Liste TP"); SqlConnection oConnection = new SqlConnection(strConnexion); SqlCommand oCommand = new SqlCommand(strRequete,oConnection); SqlDataReader dr; try { oConnection.Open(); dr = oCommand.ExecuteReader(CommandBehavior.CloseConnection); while(dr.Read()) { DDLTest.Items.Add(new ListItem (dr[0].ToString())); } // DropDownList1.SelectedValueChanged += new EventHandler (DDLTest_SelectedValueChanged); // DDLTest.DataSource = "Liste TP"; // DDLTest.Text = "PROFESSIONNEL DE SANTE"; // DDLTest.Value = "PROFESSIONNEL DE SANTE"; // oConnection.Close(); } catch {} finally {oConnection.Close();} } protected override void RenderWebPart(HtmlTextWriter output) { foreach (Control ctl in this.Controls) ctl.RenderControl (output); } protected override void CreateChildControls() { // Liste déroulante Label lblSelectNom = new Label(); lblSelectNom.Font.Bold = true; lblSelectNom.Text = "Choisissez un nom "; this.Controls.Add(lblSelectNom); this.Controls.Add(DDLTest); base.CreateChildControls(); } } }