"Tim::.." <myatix_at_hotmail.com> wrote in message
news

42FB520-E654-4D72-BFA6-(E-Mail Removed)...
> Can someone please tell me how I turn an ItemTemplate into a link? I don't
> what to use a HyperlinkColumn as I have two lines in one column in the
> datagrid coming from different sources!
>
> I would like to turn the top time into a link!
>
> EG:Have <%# Container.DataItem("header")%> as a link
>
> <a href="default.aspx?id= <%# Container.DataItem("itemID")%>"><%#
> Container.DataItem("header")%> </a>
Here is how I do mine with a Hyperlink (go directly to another page),
ImageButton and Linkbutton (go to a function then you may or may not go to
another page)
<asp:TemplateColumn SortExpression="JobTitle" ItemStyle-VerticalAlign="Top"
HeaderText="Job Title">
<itemtemplate>
<asp:hyperlink text='<%# Container.DataItem("JobTitle")%>'
NavigateUrl='<%# "displayPosition.aspx?PositionID=" &
Container.DataItem("PositionID") %>' runat="server" /><br>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Resume" ItemStyle-CssClass="CenterCell"
ItemStyle-Width="60px">
<itemtemplate>
<asp:ImageButton id="Date"
visible="false"
OnClick="Resume_Click"
width="12px"
Height="12px"
ImageUrl="../../images/taskCompleted2.gif"
ToolTip='<%# Container.DataItem("Date")%>'
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn ItemStyle-Width="45" FooterStyle-Width="45">
<itemtemplate>
<asp:LinkButton CommandName="Delete" Text="Delete" ID="btnDelete"
runat="server" />
</itemtemplate>
<asp:TemplateColumn
This one is handled would be handled by the DataGrids events (testing for
e.commandname="Delete" in this case):
.....
OnItemCreated="DataGrid_ItemCreated"
OnItemDataBound="DataGrid1_ItemDataBound"
OnItemCommand="DataInsert"
OnEditCommand="DataEdit"
OnCancelCommand="DataCancel"
OnUpdateCommand="DataUpdate"
.....
<asp:TemplateColumn ItemStyle-Width="45" FooterStyle-Width="45">
<itemtemplate>
<asp:LinkButton Text="Delete" OnClick="Delete_Click" ID="btnDelete"
runat="server" />
</itemtemplate>
</asp:TemplateColumn>
This one would be handled by the "Delete_Click" event.
HTH
Tom
>
> This doesn't work but I wondered if there was a nother way to achieve the
> same thing!
>
> Thanks
>
> ---code---
> <asp:TemplateColumn HeaderText="Event" HeaderStyle-Width="80%">
> <ItemStyle HorizontalAlign="Left" Width="80%"></ItemStyle>
> <ItemTemplate>
> <b>
> <%# Container.DataItem("header")%>
> </b><br>
> <%# Container.DataItem("EventLocation")%>
> </ItemTemplate>
> </asp:TemplateColumn>