Hi

Can any one tell my how can i download a file from MySql through dropdownlist

What i'm trying to do is i created a dropdownlist and shows all the file name in that dropdownlist now i want user to be able to download that file when they select any item on the list. Once they click on any item on the list it should popup a download window that they can click on SaveAs button to download that file.

I have saved only a link in the database and the actual file is saved in a folder i created

please help!!

thanks.

Thank you sufyan2011 for helping me. It really helped :D

hey i tried this one

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

        Response.Redirect("../meeting/"+ DropDownList1.SelectedItem.Value  );


    }

the i click on any filename to download and it did work but only just the first time only. The second time i try to click on the other file but this error was shown

Forbidden
You do not have permission to access this document.

what should i do?

thanks.

now i have a problem with the dropdownlist selectedindexchanged event is fire only the 0th index no mather in what index i clicked on
so here comes the code

    private void loadData()
    {

        DataTable DT = new DataTable();
        OdbcCommand cmd;
        OdbcConnection conn = new OdbcConnection(constr);
        if (conn.State == ConnectionState.Closed)
        {
            conn.Open();
            OdbcCommand sql = new OdbcCommand("SET CHARACTER SET `tis620`", conn);
            sql.ExecuteNonQuery();
            sql.Dispose();
        }

        cmd = new OdbcCommand("SELECT ifnull( filename, '' ) AS filename,name FROM `abt_meeting_topic` left join  abt_meeting on abt_meeting.aid = abt_meeting_topic.id   ", conn);

        try
        {
            OdbcDataReader dReader = cmd.ExecuteReader();

            {
                DropDownList1.DataSource = dReader;
                DropDownList1.DataTextField = "name";
                DropDownList1.DataValueField = "filename";
                DropDownList1.DataBind();
                dReader.Close();

            }
        }
        catch (Exception ex)
        {
           Response.Write(Utility.MessageBox("ไม่สามารถเรียกข้อมูลได้ กรุณาแจ้งผู้ดูแลระบบ (Error : " + ex + ")"));
        }
        if (conn.State == ConnectionState.Open)
        { conn.Close(); conn.Dispose(); }
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

            Response.Write("../meeting/" + DropDownList1.SelectedItem.Text);

    }

every comment appreciated.

  • Correct the above code

Actually I used Response.Redirect instead of Response.Write

 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {

                Response.Redirect("../meeting/" + DropDownList1.SelectedItem.Text);

        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.