473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataGrid Link Question

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>
Nov 19 '05 #1
1 994
"Tim::.." <myatix_at_hotmail.com> wrote in message
news:D4**********************************@microsof t.com...
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>

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Scott | last post by:
Hi all. A few days ago i ask this question and got a good quick response. I tried out what they said and it worked. However I have now come to try the same thing in another program and it...
2
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last,...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
5
by: Luis E Valencia | last post by:
I need a link on a datagrid, the link must have fields of the database Like this acciones.aspx?iddireccion=1&idindicador=4 Thanks
7
by: Bart Schelkens | last post by:
Hi, I have 2 more questions : 1. Can I fill a datagrid by using a DataReader or does it have to be a DataSet or a DataView? 2. In my datagrid I need to display two images and one of does...
3
by: Danky | last post by:
Hello Masters! Anyone can help me with the datagrid, well, the app load a lot of data from DB and it show on the datagrid, and well, I need to allow paging and.... the issue is with the event...
2
by: Fabrice | last post by:
Hello, First, thanks to felix for his answer. But :-( , I'm feeling newbie :! I' don't understand all the situation. The trouble : Always in the road whith my Datagrid and my ItemTemplate...
4
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
7
by: Peter | last post by:
One time I posted a question about DataGrid and someone replied and give me a link to a website with all kinds of info / examples on DataGrid, I saved the link but I can not find it now, it's...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.