Hello, I am trying to get data with raddropdownlist and in case the item value selected equals to "nouveau_scénario" it will open automaticly another form else messagebox will be showen but nothing happen in both cases.
I developed this function to get data from SQLSERVER database (this works correctly ) :
private void Combobox_scénario1()
{
string constr = @"Data Source=****;Initial Catalog=****;User ID=****;Password=****";
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlDataAdapter sda = new SqlDataAdapter("SELECT [LIBELLE],[OID] FROM [AffecAnalytique].[dbo].[DESCRIPTIF] order by [DATEMODIF] DESC", con))
{
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlDataAdapter sda = new SqlDataAdapter("SELECT [LIBELLE],[OID] FROM [AffecAnalytique].[dbo].[DESCRIPTIF] order by [DATEMODIF] DESC", con))
{
//Fill the DataTable with records from Table.
DataTable dt = new DataTable();
sda.Fill(dt);
//Insert the Default Item to DataTable.
DataRow row = dt.NewRow();
radDropDownListElement2.Text = "Choix du Scénario";
row[0] = "Nouveau_scénario";
dt.Rows.InsertAt(row, 0);
//Assign DataTable as DataSource.
radDropDownListElement2.DataSource = dt;
radDropDownListElement2.DisplayMember = "LIBELLE";
radDropDownListElement2.ValueMember = "OID";
}
}
}
here the function of selected index of raddropdownlist :
private void radDropDownListElement2_Click(object sender, EventArgs e)
{
Console.WriteLine("fef :"+radDropDownListElement2.SelectedValue);
if (string.IsNullOrEmpty(textBox3.Text) || textBox3.Text == "System.Data.DataRowView")
{
MessageBox.Show(" Veuillez sélectionner un scénario ");
}
else if (radDropDownListElement2.Text == "Nouveau_scénario")
{
this.IsMdiContainer = true;
Nouveau_Scenario = new Form_Nouveau_Scénario();
Nouveau_Scenario.MdiParent = this;
Nouveau_Scenario.Show();
}
else
{
string message1 = radDropDownListElement2.SelectedValue.ToString();
string message2 = radDropDownListElement2.Text;
textBox3.Text = message2;
textBox4.Text = message1;
}
}