Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Width property won't work with my Hyperlinks in DataGrid 1

Status
Not open for further replies.

ookete

Programmer
Oct 5, 2004
180
US
Hello, I am new to ASP.NET and I am using a TemplateColumn in a datagrid as follows, but the width property seems to do nothing (really a pain when the image is large):
Code:
<asp:TemplateColumn HeaderText="My Image">
   <ItemTemplate>
      <asp:HyperLink ImageUrl='<%# DataBinder.Eval(Container.DataItem, "FilePath")) %>'
       Width="100px"
       NavigateUrl='[URL unfurl="true"]http://myPage.html'[/URL] Target=_blank Runat="server" />
   </ItemTemplate>
</asp:TemplateColumn>
When I use an Image instead of a hyperlink, the width property works great, but then I lose the hyperlink capability. Am I doing something wrong, or does Width not really supposed to control the image width? Thanks for your help! :)
 
The width property will only control the width of the hyperlink, not the image so depending on the size of the image you may not notice any difference (which seems to be the case here).

Instead, you could use a standard anchor tag and an image server control. e.g.
Code:
<a href="mypage.aspx"><asp:Image ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "FilePath")) %>' /></a>


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top