Display Image in gridview from the path which is in database

  

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns = "false"    Font-Names = "Arial" >

    <Columns>

       <asp:ImageField DataImageUrlField=" imagepath " ControlStyle-Width="100"        ControlStyle-Height = "100" HeaderText = "Preview Image"/>   

    </Columns>

    </asp:GridView>

 

 

   DataTable dt = new DataTable();

 

        String strConnString = "your connectionsting";

       

        string strQuery = "select imagepath from table1";

 

        SqlConnection con = new SqlConnection(strConnString);

        SqlCommand cmd = new SqlCommand(strQuery,con);

        SqlDataAdapter sda = new SqlDataAdapter();

            con.Open();

            sda.SelectCommand = cmd;

            sda.Fill(dt);

            GridView1.DataSource = dt;

            GridView1.DataBind();

            con.Close();

 

Ebook Download
View all
Learn
View all