Display Image in gridview from the path which is in database

By Hiren Soni Aug 19, 2010
Display Image in gridview. and the path is stored in the databse.

  

    <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();

 

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs