DropDown List non remplie :(
Bonjour tout le monde,
J essais de remplir une DDL, mais la DDL n est jamais remplie et je vois pas d'ou vient l erreur.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public void Page_Load(object sender, System.EventArgs e)
{
oCon = new System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings.Get("StrConn"));
DDL_Region.AutoPostBack = true ;
if (!Page.IsPostBack)
{
oCon.Open();
InitializeDDL ();
}
// Put user code to initialize the page here
} |
Et le DDl Initialise
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public void InitializeDDL ()
{
//Fill Region DDL
string strSQL;
strSQL = "Select Distinct RegionName_En from TBL_Region order by RegionName_En";
Cmd = new SqlCommand(strSQL, oCon);
oCon.Open();
if (oCon.State==ConnectionState.Open)
{
dReader = Cmd.ExecuteReader();
DDL_Region.DataSource = dReader;
DDL_Region.DataTextField= "RegionName_En";
DDL_Region.DataValueField = "RegionName_En";
DDL_Region.DataBind();
DDL_Region.Items.Insert(0, "--Please select a region--");
DDL_Region.Items.Insert(1, "--All Regions--");
DDL_Region.SelectedIndex =0;
dReader.Close();
} |
Merci par avance pour tout aide..
8O