PC Review


Reply
Thread Tools Rate Thread

DataGrid Link Question

 
 
=?Utf-8?B?VGltOjouLg==?=
Guest
Posts: n/a
 
      8th Aug 2005
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>

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>
 
Reply With Quote
 
 
 
 
tshad
Guest
Posts: n/a
 
      8th Aug 2005
"Tim::.." <myatix_at_hotmail.com> wrote in message
news42FB520-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>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tables: Appending Data, Link or Not to Link, That's My Question... MJ Microsoft Access 6 1st May 2010 01:57 PM
Link in DataGrid Looch Microsoft ASP .NET 2 4th Jun 2007 03:10 PM
I need a link on a datagrid Luis E Valencia Microsoft ASP .NET 5 29th May 2004 03:40 AM
DataGrid link temp Microsoft ASP .NET 0 9th Mar 2004 11:39 AM
Re: Datagrid and hyper link question? k-re Microsoft ASP .NET 1 25th Jun 2003 02:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:03 AM.