Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Display an images in Datagrid

Reply
Thread Tools

Display an images in Datagrid

 
 
sameer
Guest
Posts: n/a
 
      12-01-2005
Hi All,
heres an easy question which for benig new , i cannot figure it out.

A datatable pulled from the database which has 10 columns is binded to a
datagrid and it shows all of them in the datagrid successfully. Now i want to
add an image next to each record inteh grid, the image is stored on the
server( not in the dabtase) but the datatable has the path of the image
(since the path is stored in the database).

The question is how can i show this image in the datagrid right next to each
record.
Woudl be great if someone points to samples.

thanks

 
Reply With Quote
 
 
 
 
Phillip Williams
Guest
Posts: n/a
 
      12-01-2005
You can add a TemplateColumn with a Image server control defined inside its
ItemTemplate:

<asp:TemplateColumn HeaderText="Person Name">
<ItemTemplate>
<asp:Image ImageUrl =<%# DataBinder.Eval(Container.DataItem, "ImagePath")%>
Runat=server ></asp:Image>
</ItemTemplate>
</asp:TemplateColumn>

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"sameer" wrote:

> Hi All,
> heres an easy question which for benig new , i cannot figure it out.
>
> A datatable pulled from the database which has 10 columns is binded to a
> datagrid and it shows all of them in the datagrid successfully. Now i want to
> add an image next to each record inteh grid, the image is stored on the
> server( not in the dabtase) but the datatable has the path of the image
> (since the path is stored in the database).
>
> The question is how can i show this image in the datagrid right next to each
> record.
> Woudl be great if someone points to samples.
>
> thanks
>

 
Reply With Quote
 
 
 
 
sameer
Guest
Posts: n/a
 
      12-01-2005
right now i did not set any template for the columns of this grid,i jsut take
the datatable and bind it to the datagrid. So when i add this template column
, woudl i have to change any properties like define all the other columns as
well? or it shold work seemless?

thanks

"Phillip Williams" wrote:

> You can add a TemplateColumn with a Image server control defined inside its
> ItemTemplate:
>
> <asp:TemplateColumn HeaderText="Person Name">
> <ItemTemplate>
> <asp:Image ImageUrl =<%# DataBinder.Eval(Container.DataItem, "ImagePath")%>
> Runat=server ></asp:Image>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "sameer" wrote:
>
> > Hi All,
> > heres an easy question which for benig new , i cannot figure it out.
> >
> > A datatable pulled from the database which has 10 columns is binded to a
> > datagrid and it shows all of them in the datagrid successfully. Now i want to
> > add an image next to each record inteh grid, the image is stored on the
> > server( not in the dabtase) but the datatable has the path of the image
> > (since the path is stored in the database).
> >
> > The question is how can i show this image in the datagrid right next to each
> > record.
> > Woudl be great if someone points to samples.
> >
> > thanks
> >

 
Reply With Quote
 
Phillip Williams
Guest
Posts: n/a
 
      12-02-2005
Hi Sameer,

Explicitly declared template columns appear first followed by the
Auto-generated columns.

---
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"sameer" wrote:

> right now i did not set any template for the columns of this grid,i jsut take
> the datatable and bind it to the datagrid. So when i add this template column
> , woudl i have to change any properties like define all the other columns as
> well? or it shold work seemless?
>
> thanks
>
> "Phillip Williams" wrote:
>
> > You can add a TemplateColumn with a Image server control defined inside its
> > ItemTemplate:
> >
> > <asp:TemplateColumn HeaderText="Person Name">
> > <ItemTemplate>
> > <asp:Image ImageUrl =<%# DataBinder.Eval(Container.DataItem, "ImagePath")%>
> > Runat=server ></asp:Image>
> > </ItemTemplate>
> > </asp:TemplateColumn>
> >
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "sameer" wrote:
> >
> > > Hi All,
> > > heres an easy question which for benig new , i cannot figure it out.
> > >
> > > A datatable pulled from the database which has 10 columns is binded to a
> > > datagrid and it shows all of them in the datagrid successfully. Now i want to
> > > add an image next to each record inteh grid, the image is stored on the
> > > server( not in the dabtase) but the datatable has the path of the image
> > > (since the path is stored in the database).
> > >
> > > The question is how can i show this image in the datagrid right next to each
> > > record.
> > > Woudl be great if someone points to samples.
> > >
> > > thanks
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display Images in datagrid Nishad ASP .Net 0 01-11-2009 01:27 PM
How to display images in datagrid column header? Alek Davis ASP .Net 4 06-14-2004 11:17 PM
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams ASP .Net 0 03-02-2004 08:35 PM
RE: Datagrid: how cut short display of a long description in a datagrid column =?Utf-8?B?U3VyZXNo?= ASP .Net 0 03-02-2004 08:31 PM
Display Images In a datagrid John Do ASP .Net 2 12-12-2003 06:26 PM



Advertisments