Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在具有3层体系结构的gridview中显示图像?_C#_Asp.net_Gridview - Fatal编程技术网

C# 如何在具有3层体系结构的gridview中显示图像?

C# 如何在具有3层体系结构的gridview中显示图像?,c#,asp.net,gridview,C#,Asp.net,Gridview,对于数据访问层: 资料来源: public string insert_details(bisuness_object user_details) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("

对于数据访问层:

资料来源:

public string insert_details(bisuness_object user_details)
{

    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
    con.Open();
    SqlCommand cmd = new SqlCommand("insert into tbl_rgsthome values(@firstname,@lastname,@emailid,@password,@address,@upload)", con);
    try
    {
        cmd.Parameters.AddWithValue("@firstname", user_details.firstname_value);
        cmd.Parameters.AddWithValue("@lastname", user_details.lastname_value);
        cmd.Parameters.AddWithValue("@emailid", user_details.emailid_value);
        cmd.Parameters.AddWithValue("@password", user_details.pass_value);
        cmd.Parameters.AddWithValue("@address", user_details.addr_value);
        cmd.Parameters.AddWithValue("@upload", user_details.fileupl_value);
      //cmd.Parameters.AddWithValue("@imagepath", user_details.imgpth_value);
        return cmd.ExecuteNonQuery().ToString();
    }
    catch (Exception show_error)
    {
        throw show_error;
    }
    finally
    {
        cmd.Dispose();
        con.Close();
        con.Dispose();
    }

}

home.aspx:

public string getimage(object ob)
{
    string img = @"/image/" + ob.ToString();
    return img;
}

protected void Button1_Click(object sender, EventArgs e)
{
    if (FileUpload1.PostedFile != null  && FileUpload1.PostedFile.FileName != "")
    {

        byte[] myimage = new byte[FileUpload1.PostedFile.ContentLength];
        HttpPostedFile Image = FileUpload1.PostedFile;
        Image.InputStream.Read(myimage, 0, (int)FileUpload1.PostedFile.ContentLength);
        bisuness_object bo = new bisuness_object();
        // cmd.Parameters.AddWithValue("@imagepath", ("@uploadimage") + filename);
        bo.firstname_value = TextBox1.Text;
        bo.lastname_value = TextBox2.Text;
        bo.emailid_value = TextBox3.Text;
        bo.pass_value = TextBox4.Text;
        bo.addr_value = TextBox6.Text;
        bo.fileupl_value = FileUpload1.FileName.ToString();
        bisuness_layer bl = new bisuness_layer();
        bind();

        try
        {
            string result = bl.record_insert(bo);
        }
        catch (Exception info)
        {
            throw info;
        }
        finally
        {
            bo = null;
            bl = null;
            bind();
        }
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";
        TextBox5.Text = "";
        TextBox6.Text = "";
    }
}
如何解决……请帮帮我
我想在gridview中动态绑定图像标签
 protected void GetDayoffer()
{

    gridview1.DataSource = bl.method();
    gridview1.DataBind();
}
通过动态地给出路径

 <asp:Image ID="image" Style="width:100px; height:100px;" runat="server" ImageUrl='<%# "~/folder/subfolder/" + Eval("id") +"."+ Eval("imagetype") %>' />

希望这将帮助您或将字节重新恢复到图像中,并将其绑定到gridview

您的gridview在哪里?