locked
Video select by databse RRS feed

  • Question

  • User-2094959909 posted

    hello everyone, 

    i have a table of operations in my database made of (Number, Name, ..................., video) so for now i have the code to add this operation yo my database and the file of video too

    so the database takes the the name of the video ( ex : video.mp4 )for now is all good, i have in another page a dropdownlist with a list of operation's numbers so when i select one of them i have also so textboxes who get filled by the rest of informations concerned by the number selected 

    so my question is how can i show the video of the operation selected (i don't have the html for the video) so that when i change selection in the list the video changes too 

    __________________________________________________________ THIS IS THE DROPDOWNLIST CODE FOR GETTING DATA AND SHOW______________________________________

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    DropDownList1.Items.Add(new ListItem("--Select--", ""));
    DropDownList1.AppendDataBoundItems = true;
    String strConnString = ConfigurationManager
    .ConnectionStrings["parallelConnectionString"].ConnectionString;
    String strQuery = "select name, surname from tblusers";
    MySqlConnection con = new MySqlConnection(strConnString);
    MySqlCommand cmd = new MySqlCommand();
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = strQuery;
    cmd.Connection = con;
    try
    {
    con.Open();
    DropDownList1.DataSource = cmd.ExecuteReader();
    DropDownList1.DataTextField = "name";
    DropDownList1.DataValueField = "surname";
    DropDownList1.DataBind();
    }
    catch (Exception ex)
    {
    throw ex;
    }
    finally
    {
    con.Close();
    con.Dispose();
    }
    }
    }

    protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
    String strConnString = ConfigurationManager
    .ConnectionStrings["parallelConnectionString"].ConnectionString;
    string strQuery = "select name, surname, username, password, role from tblusers where name = @name";
    MySqlConnection con = new MySqlConnection(strConnString);
    MySqlCommand cmd = new MySqlCommand();
    cmd.Parameters.AddWithValue("@name", DropDownList1.SelectedItem.Text);
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = strQuery;
    cmd.Connection = con;

    try
    {
    con.Open();
    MySqlDataReader sdr = cmd.ExecuteReader();
    if (sdr.HasRows) {
    while (sdr.Read())
    {
    TextBox1.Text = sdr[0].ToString();
    TextBox2.Text = sdr[1].ToString();
    TextBox3.Text = sdr[2].ToString();
    TextBox4.Text = sdr[3].ToString();
    TextBox5.Text = sdr[4].ToString();
    }
    }
    else
    {
    TextBox1.Text = "not found";
    }

    }
    finally
    {
    con.Close();
    con.Dispose();
    }

    }

    thanks in advance 

    Omar.

    Thursday, July 26, 2018 12:11 AM

All replies