Click here to Skip to main content
15,888,217 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi
I want show my images in data grid view in 3 columns that each columns image differ than other
please help me.
change the code.
thanks.

now:
|
|
|
|

want:
| | |
| | |
| | |
XML
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                        <Columns>
                            <asp:TemplateField>
                              <ItemTemplate>
                              <img src='<%# GetImageUrl(Eval("FullName")) %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
Posted
Updated 3-Aug-12 10:21am
v2
Comments
Kenneth Haugland 3-Aug-12 16:25pm    
You should perhaps add more columns then?
Behnam Mohammadi 3-Aug-12 16:28pm    
No if i add another column, that column repeat last column in that row data.
ZurdoDev 3-Aug-12 16:38pm    
Add another column but change the src to be from a different field in your SQL.
Behnam Mohammadi 3-Aug-12 16:40pm    
i want change it by template field but i don't know?
ZurdoDev 3-Aug-12 16:50pm    
I do not fully understand what you are asking. You can just copy the <asp:TemplateField> that you have now and just change the img src part.

1 solution

You should do something like this:
JavaScript
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" xmlns:asp="#unknown">
                        <columns>
                            <asp:templatefield>
                              <itemtemplate>
                              <img src="<%# GetImageUrl(Eval("FullName1")) %>" />
                                </itemtemplate>
                            </asp:templatefield>
                        </columns>
              <columns>
                            <asp:templatefield>
                              <itemtemplate>
                              <img src="<%# GetImageUrl(Eval("FullName2")) %>" />
                                </itemtemplate>
                            </asp:templatefield>
                        </columns>
              <columns>
                            <asp:templatefield>
                              <itemtemplate>
                              <img src="<%# GetImageUrl(Eval("FullName3")) %>" />
                                </itemtemplate>
                            </asp:templatefield>
                        </columns>
                    </asp:gridview>


With a class behind that contains the names FullName1 etc...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900