Home All Groups Group Topic Archive Search About
Author
1 Dec 2005 8:16 PM
sameer
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

Author
1 Dec 2005 10:31 PM
Phillip Williams
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>

Show quoteHide quote
"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
>
Author
1 Dec 2005 10:40 PM
sameer
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

Show quoteHide quote
"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
> >
Author
2 Dec 2005 3:35 PM
Phillip Williams
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


Show quoteHide quote
"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
> > >