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!

using an image for the hyperlink

Status
Not open for further replies.

NewFromMattel

Programmer
Jun 24, 2003
41
US
I'm new to ASP.net, using C#, and I'm doing a pretty good job of figuring things out. Slowly, but getting there. I bought the Programming ASP.Net O'Reilly book. Very good book. But, here's my question.

I'm getting the hang of datagrids, but I want to use my own images for edit, cancel, etc but see no way to do that.

Any suggestions?

thanks
 
Ok, I've found this.

For my first column, I use:
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink ImageUrl=&quot;images/pencilEdit.gif&quot; Runat=&quot;server&quot; ID=&quot;editMovie&quot; NAME=&quot;editMovie&quot;/>
</ItemTemplate>
</asp:TemplateColumn>

But now I'm trying to set the NavigateUrl parameter of this HyperLink tag, but can't set it. I can either set it to some text, or, the &quot;evaluated&quot; value of MovieID (the data from the database). But can't concatenate them together for a full url for an edit link.

Any ideas?
 
Ok, this works. Back to the basics of HTML. ha. But is there an ASP.net/C# way to do this?

<asp:TemplateColumn>
<ItemTemplate>
<a href='editMovie.aspx?movieID=<%# Convert.ToString(DataBinder.Eval(Container.DataItem,&quot;MovieID&quot;)) %>'>
<img src=&quot;images/pencilEdit.gif&quot; border=&quot;0&quot;>
</a>
</ItemTemplate>
</asp:TemplateColumn>
 
Ok, here's the answer:

<asp:HyperLink
ImageUrl=&quot;icon0.gif&quot;
NavigateUrl='<%# DataBinder.Eval (Container.DataItem,&quot;ID&quot;, &quot;no1.aspx?ID1={0}&quot;) %>'
Text='<%# DataBinder.Eval (Container.DataItem,&quot;IDtitle&quot;, &quot;Some text to show before the db title of the thing you working on {0}&quot;) %>'
Runat=&quot;server&quot; ID=&quot;editLink&quot; />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top