Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 24th, 2005, 12:24 AM
Authorized User
 
Join Date: Nov 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Selectively showing an icon in datagrid

Hello

What i want to do is display a grid from a table, however if there is data in a text field then i want to display an icon or hyperlink which takes the user to another form to view the contents of the field otherwise the column is blank.

Regards

Guy



 
Old November 24th, 2005, 01:06 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

First create a Hyperlink column, or template column with a Hyperlink or icon.
Then use the ItemDataBound event of the grid. Check the column in question there. If data exists show the hyperlink, otherwise set the Visible property to FALSE.

 
Old November 24th, 2005, 08:26 PM
Authorized User
 
Join Date: Nov 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for replying so quickly.

I have added a hyperlink to my grid, this is the actual code

<asp:HyperLinkColumn HeaderText="Details" DataNavigateUrlField="details0"
Text="<img src='images/view.gif' border='0'>"
DataNavigateUrlFormatString="javascript:varwin=win dow.open('Log_Details.aspx?detail={0}', null, 'top=400, left=400, width=600, height=250');"></asp:HyperLinkColumn>

I just have two questions
In the ItemDataBound event i check that we are looking at data row
(not header or footer) but am not sure how to reference the actual column to make it visible

Secondly
if the user clicks on the gif, i want to open a popup with some text
which it seems to work ok. But when the popup opens on the bottom of the form, the calling form which has the grid on it blanks out and only the tag [Object] is visible.

Any ideas what i am doing wrong????

Thanks

Guy

 
Old November 25th, 2005, 01:19 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

1. You need to know index of the column you want. The index is 0 based. So if the 4th column is the one you want, the index is 5. Ex:

Dim hl As New HyperLink
hl1 = CType(e.Item.Cells(HyperLink Column Index).Controls(0), HyperLink)
If CInt(e.Item.Cells(Your Column Index).Text) = "" Then
   hl.Visible = False
End If

2. I am not sure why that is happening. Try tracing through your code to see if you can find the problem.

Jim







Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet_Change executing selectively lfrench Excel VBA 3 April 3rd, 2007 03:59 PM
Datagrid icon in Toolbox in VB.NET 2005 dimeanel Visual Basic 2005 Basics 1 April 12th, 2006 09:38 PM
Showing Hyperlink in Winforms Datagrid control livehed C# 0 January 20th, 2006 01:56 PM
to display an icon in datagrid deeraj ADO.NET 4 March 30th, 2005 02:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.