Display datagrid records

P

Peter

Hi All

I currently use the following codes to display images from a DataGrid but it
can only display 1 per line. May I know whether how can I display multiple
pics(records) per line in the DataGrid ? Or if DataGrid is not the best way
to do so, any other better methods to do the task ?

<asp:DataGrid id="myGrid" runat="server" CellPadding="2" BorderWidth="0px"
Width="100%" CssClass="cntltext" DataKeyField="Filename"
AutoGenerateColumes="False" AutoGenerateColumns="False">
<HeaderStyle font-bold="True" forecolor="PaleGoldenrod"
backcolor="MidnightBlue"></HeaderStyle>
<AlternatingItemStyle backcolor="#D0D0FF"></AlternatingItemStyle>
<Columns>
<asp:TemplateColumn HeaderText="Image View">
<ItemTemplate>
<img src="<%# DataBinder.Eval(Container.DataItem,"ImageFullPath") %>"/
width="100" height="75" >
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

Thanks
Peter
 
G

Guest

Hi All

I currently use the following codes to display images from a DataGrid but it
can only display 1 per line.   May I know whether how can I display multiple
pics(records) per line in the DataGrid ?  Or if DataGrid is not the best way
to do so, any other better methods to do the task ?

 <asp:DataGrid id="myGrid" runat="server" CellPadding="2" BorderWidth="0px"
Width="100%" CssClass="cntltext" DataKeyField="Filename"
AutoGenerateColumes="False" AutoGenerateColumns="False">
  <HeaderStyle font-bold="True" forecolor="PaleGoldenrod"
backcolor="MidnightBlue"></HeaderStyle>
  <AlternatingItemStyle backcolor="#D0D0FF"></AlternatingItemStyle>
  <Columns>
      <asp:TemplateColumn HeaderText="Image View">
   <ItemTemplate>
    <img src="<%# DataBinder.Eval(Container.DataItem,"ImageFullPath") %>"/
width="100" height="75" >
   </ItemTemplate>
      </asp:TemplateColumn>
  </Columns>
 </asp:DataGrid>

Thanks
Peter

If you have fixed number of images for each item (for example, 3) then
you can just have 3 <img /> in the <ItemTemplate> tag. If number may
vary the best choice would probably be a nested datalist
 
P

Peter

Hi Mark

Thanks for your help again. My images per row cam from different records rather than different fields. Any suggestions, if I need
to change from DataGrid from GridView (assuming the datasourse part is unchanged, how would I change the code with DataGrid par ?

Thanks
Peter
 
P

Peter

Hi Alex

No, the number of records are not fixed but I want to control the number of pics per row instead of only 1

Thanks
Peter

Hi All

I currently use the following codes to display images from a DataGrid but it
can only display 1 per line. May I know whether how can I display multiple
pics(records) per line in the DataGrid ? Or if DataGrid is not the best way
to do so, any other better methods to do the task ?

<asp:DataGrid id="myGrid" runat="server" CellPadding="2" BorderWidth="0px"
Width="100%" CssClass="cntltext" DataKeyField="Filename"
AutoGenerateColumes="False" AutoGenerateColumns="False">
<HeaderStyle font-bold="True" forecolor="PaleGoldenrod"
backcolor="MidnightBlue"></HeaderStyle>
<AlternatingItemStyle backcolor="#D0D0FF"></AlternatingItemStyle>
<Columns>
<asp:TemplateColumn HeaderText="Image View">
<ItemTemplate>
<img src="<%# DataBinder.Eval(Container.DataItem,"ImageFullPath") %>"/
width="100" height="75" >
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

Thanks
Peter

If you have fixed number of images for each item (for example, 3) then
you can just have 3 <img /> in the <ItemTemplate> tag. If number may
vary the best choice would probably be a nested datalist
 
P

Peter

The DataSource comes from below where dvImageList is a DataView object.

myGrid.DataSource = dvImageList;
myGrid.DataBind();


Thhanks

Peter said:
Hi Mark

Thanks for your help again. My images per row cam from different records rather than different fields. Any suggestions, if I
need to change from DataGrid from GridView (assuming the datasourse part is unchanged, how would I change the code with DataGrid
par ?

Thanks
Peter
 
P

Peter

I tried to modify my codes as below and its so strange that ALL fields in myGrid appears as individual columns automatically ? As
seen below, I expect nothing to be shown but I guess it's not what I expected.

<asp:GridView id="myGrid" runat="server" CellPadding="2" BorderWidth="0px" Width="100%" CssClass="cntltext" >
<HeaderStyle font-bold="True" forecolor="PaleGoldenrod" backcolor="MidnightBlue"></HeaderStyle>
<Columns>
<asp:TemplateField>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Thanks
Peter

Peter said:
The DataSource comes from below where dvImageList is a DataView object.

myGrid.DataSource = dvImageList;
myGrid.DataBind();


Thhanks
 
P

Peter

Sorry guys, I ommit the AutoGenerateColumns and that's why all columns appeared. Can you give me a hand on how to put fields on
multiple records on the same line ?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top