Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 24th, 2005, 12:24 AM
Authorized User
 
Join Date: Nov 2005
Location: , , Australia.
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



  #2 (permalink)  
Old November 24th, 2005, 01:06 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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.

  #3 (permalink)  
Old November 24th, 2005, 08:26 PM
Authorized User
 
Join Date: Nov 2005
Location: , , Australia.
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

  #4 (permalink)  
Old November 25th, 2005, 01:19 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
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


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.