473,403 Members | 2,354 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,403 software developers and data experts.

Converting a column in a grid to link

Hi I want to convert a column to a link. All examples I
have seen works with bound columns. I have the following
grid:
<asp:datagrid runat="server" id="__theDetailsGrid"
cellpadding="2" cellspacing="0"
OnItemDataBound="Details_Item_Bound">
</asp:datagrid>

It is bound during runtime to a DataTable that is bound to
a SqlDataAdapter. The Details_Item_Bound function changes
the background color based on a value. I have been able to
get that to work with the following code:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
if(e.Item.Cells[1].Text == "FAILED")
{
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}
}

Basically what I would like to do is to set the text in
column number 3 to a hypertext link that will point to
another page if the value is "FAILED" in column 1
Hope you guys understand what I would like to acomplish.
Nov 17 '05 #1
4 1385
I think I understand what you want.

Can you do this, or something along this idea?:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
if(e.Item.Cells[1].Text == "FAILED")
{
//Add this to make the 4th column (3rd index) a link.
e.Item.Cells[3].Text = "<a href=\"AnotherPage.aspx\">" +
e.Item.Cells[3].Text + "</a>";
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}

"John Doe" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl... Hi I want to convert a column to a link. All examples I
have seen works with bound columns. I have the following
grid:
<asp:datagrid runat="server" id="__theDetailsGrid"
cellpadding="2" cellspacing="0"
OnItemDataBound="Details_Item_Bound">
</asp:datagrid>

It is bound during runtime to a DataTable that is bound to
a SqlDataAdapter. The Details_Item_Bound function changes
the background color based on a value. I have been able to
get that to work with the following code:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
if(e.Item.Cells[1].Text == "FAILED")
{
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}
}

Basically what I would like to do is to set the text in
column number 3 to a hypertext link that will point to
another page if the value is "FAILED" in column 1
Hope you guys understand what I would like to acomplish.

Nov 17 '05 #2
I think I understand what you want.

Can you do this, or something along this idea?:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
if(e.Item.Cells[1].Text == "FAILED")
{
//Add this to make the 4th column (3rd index) a link.
e.Item.Cells[3].Text = "<a href=\"AnotherPage.aspx\">" +
e.Item.Cells[3].Text + "</a>";
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}

"John Doe" <an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl... Hi I want to convert a column to a link. All examples I
have seen works with bound columns. I have the following
grid:
<asp:datagrid runat="server" id="__theDetailsGrid"
cellpadding="2" cellspacing="0"
OnItemDataBound="Details_Item_Bound">
</asp:datagrid>

It is bound during runtime to a DataTable that is bound to
a SqlDataAdapter. The Details_Item_Bound function changes
the background color based on a value. I have been able to
get that to work with the following code:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
if(e.Item.Cells[1].Text == "FAILED")
{
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}
}

Basically what I would like to do is to set the text in
column number 3 to a hypertext link that will point to
another page if the value is "FAILED" in column 1
Hope you guys understand what I would like to acomplish.

Nov 17 '05 #3
Hi Darrin
Thanks a million that helped me.
-----Original Message-----
I think I understand what you want.

Can you do this, or something along this idea?:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem)) {
if(e.Item.Cells[1].Text == "FAILED")
{
//Add this to make the 4th column (3rd index)

a link. e.Item.Cells[3].Text = "<a href=\"AnotherPage.aspx\">" +e.Item.Cells[3].Text + "</a>";
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}

"John Doe" <an*******@discussions.microsoft.com> wrote in

messagenews:05****************************@phx.gbl...
Hi I want to convert a column to a link. All examples I
have seen works with bound columns. I have the following
grid:
<asp:datagrid runat="server" id="__theDetailsGrid"
cellpadding="2" cellspacing="0"
OnItemDataBound="Details_Item_Bound">
</asp:datagrid>

It is bound during runtime to a DataTable that is bound to a SqlDataAdapter. The Details_Item_Bound function changes the background color based on a value. I have been able to get that to work with the following code:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem)) {
if(e.Item.Cells[1].Text == "FAILED")
{
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}
}

Basically what I would like to do is to set the text in
column number 3 to a hypertext link that will point to
another page if the value is "FAILED" in column 1
Hope you guys understand what I would like to acomplish.

.

Nov 17 '05 #4
Hi Darrin
Thanks a million that helped me.
-----Original Message-----
I think I understand what you want.

Can you do this, or something along this idea?:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem)) {
if(e.Item.Cells[1].Text == "FAILED")
{
//Add this to make the 4th column (3rd index)

a link. e.Item.Cells[3].Text = "<a href=\"AnotherPage.aspx\">" +e.Item.Cells[3].Text + "</a>";
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}

"John Doe" <an*******@discussions.microsoft.com> wrote in

messagenews:05****************************@phx.gbl...
Hi I want to convert a column to a link. All examples I
have seen works with bound columns. I have the following
grid:
<asp:datagrid runat="server" id="__theDetailsGrid"
cellpadding="2" cellspacing="0"
OnItemDataBound="Details_Item_Bound">
</asp:datagrid>

It is bound during runtime to a DataTable that is bound to a SqlDataAdapter. The Details_Item_Bound function changes the background color based on a value. I have been able to get that to work with the following code:

private void Details_Item_Bound(object sender,
DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem)) {
if(e.Item.Cells[1].Text == "FAILED")
{
foreach(TableCell c in e.Item.Cells)
{
c.BackColor = System.Drawing.Color.Red;
}
}
}
}
}

Basically what I would like to do is to set the text in
column number 3 to a hypertext link that will point to
another page if the value is "FAILED" in column 1
Hope you guys understand what I would like to acomplish.

.

Nov 17 '05 #5

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

Similar topics

0
by: John Doe | last post by:
Hi I want to convert a column to a link. All examples I have seen works with bound columns. I have the following grid: <asp:datagrid runat="server" id="__theDetailsGrid" cellpadding="2"...
2
by: Remy | last post by:
Hi I would like to put a link into the Footer of the first column of an ASP.NET 2.0 GridView. By first column I mean the column where it normally displayes the Edit and Delete link. I've built...
2
by: Valli | last post by:
Hi, I am using a gridview to display data from table. In the gridview, there are 5 columns in which one column contains link name(eg. http://www.msn.com). I want to show this link as an...
1
by: rogerford | last post by:
I have a grid which i bind with values from Database. I have events to edit and update the grid. I am not using SqlDatasource to connect to DB. Rather i am doing the updating of the grid...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.