How to retrieve Image from database to gridview in

2019-08-31 01:59发布

问题:

I just want to store and retrive image from database to gridview . After the image is store i want to display the stored image in a grid view. How to do?

retrieve Image from database to gridview in asp.net

protected void Page_Load(object sender, EventArgs e)
        {

            if (!this.IsPostBack)
            {
                BindGridView();
            }

        }
        private void BindGridView()
        {
            string constr = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
            SqlConnection con = new SqlConnection(constr);
            SqlCommand cmd = new SqlCommand("select * from Student", con);
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }