DataSource Der DropdownList

Hallo allerseits ich habe ein problem über die dropdown-Liste. Ich bin mit dropdown-Liste Datenquelle. Wie bekomme ich, die Wert, die ich ausgewählt habe ?

//I need a if statement here because my programme doesn't know which value of dropdown list selected and I don't know how to use this with datasource.

if(//if I select quiz 1 from dropdown list ,quiz 1 should list questions.)

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);

string chooce = "Select Quiz from tblQuiz where Quiz=1 ";
SqlCommand userExist = new SqlCommand(chooce, con);
con.Open();
int temp = Convert.ToInt32(userExist.ExecuteScalar().ToString());

if (temp == 1)
{
    if (rbList.Items[0].Selected == true)
    {
        string cmdStr = "Select Question from tblQuiz where ID=1";
        SqlCommand quest = new SqlCommand(cmdStr, con);
        lblque.Text = quest.ExecuteScalar().ToString();
        con.Close();
    } 
  • Der code, den Sie aufgeführt sind, nicht wirklich übereinstimmen, die von Ihnen gestellte Frage. Wir benötigen den Namen/id von dem drop-down-Liste den Typ der Datenquelle, die Sie verwendet, und die Art, wie Sie gebunden datasource auf die drop-down-Liste, um eine Antwort auf diese effektiv.
InformationsquelleAutor Alijohnn | 2012-12-31
Schreibe einen Kommentar