如何将字符串中的单词转换为下拉列表数据项asp.net

本文关键字:下拉列表 数据项 asp net 转换 单词 字符串 | 更新日期: 2023-09-27 18:28:37

在assign.aspx页面中我有

    foreach (ListItem li in CheckBoxList1.Items)
    {
        if (li.Selected)
        {
            str1+=li.Value+" ";
        }
    }                
    sql = " insert into assgnmovie values ('"+mvnm+"','"+thnm+"','"+date+"','"+str1+"')";
    SqlDatabase.Insert(sql);

}现在在booking.aspx页面

protected void ddlMov_SelectedIndexChanged(object sender, EventArgs e)
{
    DataSet ds = new DataSet();
    SqlDataAdapter adp = new SqlDataAdapter("select thname from assgnmovie where mvname='"+ddlMov.SelectedItem.Value+"'",con);
    adp.Fill(ds);
    ddlTheater.DataSource = ds;
    ddlTheater.DataValueField = "thname";
    ddlTheater.DataBind();
    ddlTheater.Items.Insert(0, new ListItem("SELECT", "0"));
}

protected void ddlTheater_SelectedIndexChanged(object sender, EventArgs e)
{
    DataSet ds = new DataSet();
    SqlDataAdapter adp = new SqlDataAdapter("select showtime from assgnmovie where mvname='"+ddlMov.SelectedItem.Value+"' and thname='"+ddlTheater.SelectedItem.Value+"'",con);
    String a = adp.ToString();
    String b = a.Substring(1, 6);
    ddlShow.Text = b;
     adp.Fill(ds);

如何拆分字符串并将单词作为ddlshow.list的数据集???

如何将字符串中的单词转换为下拉列表数据项asp.net

试试这样的东西:

protected void ddlTheater_SelectedIndexChanged(object sender, EventArgs e)
{
    DataSet ds = new DataSet();
    SqlDataAdapter adp = new SqlDataAdapter("select showtime from assgnmovie where mvname='"+ddlMov.SelectedItem.Value+"' and thname='"+ddlTheater.SelectedItem.Value+"'",con);
    String a = adp.ToString();
    String b = a.Substring(1, 6);
    ddlShow.Text = b;
    adp.Fill(ds);
    ddlTheater.DataSource = ds;
    ddlTheater.DataValueField = "showtime";
    ddlTheater.DataBind();
 }