Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

how to display image in gridview from imagename field sqlserver

$
0
0

I have table movie:

movies
movie_Id int
title varchar (50)
image varchar(50)

I insert into movie table:

movie_Id

title

image

1

Hyde Park on Hudson

1.jpg

2

Playing for Keeps

2.jpg

3

Cheerful Weather for the Wedding

3.jpg

4

Heleno

4.jpg

6

Deadfall

6.jpg


How to display the a image  from folder  in gridview which image name stored in sql server:

help me I want to use imagefield or img in gridview

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
          DataKeyNames="movie_Id" DataSourceID="SqlDataSource1"><Columns><asp:BoundField DataField="movie_Id" HeaderText="movie_Id"
                InsertVisible="False" ReadOnly="True" SortExpression="movie_Id" /><asp:BoundField DataField="title" HeaderText="title" SortExpression="title" /><asp:BoundField DataField="year" HeaderText="year" SortExpression="year" /><asp:BoundField DataField="image" HeaderText="image" SortExpression="image" /><asp:BoundField DataField="description" HeaderText="description"
                SortExpression="description" /><a href ="moviepic/<%#DataBinder.Eval(Container, "DataItem.image")%>" target ="_blank" ><img border="0" src="moviepic/<%#DataBinder.Eval(Container, "DataItem.image")%>"    width="200" height="200"></a><asp:ImageField HeaderText="poster"></asp:ImageField></Columns></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server"
          ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
          SelectCommand="SELECT movie_Id, title, year, image, description FROM movies WHERE (title = @title)"><SelectParameters><asp:ControlParameter ControlID="TextBox1" Name="title" PropertyName="Text"
                  Type="String" /></SelectParameters></asp:SqlDataSource>


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>