navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Hyperlink in DataGrid

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Expression Web Help >> Hyperlink in DataGrid
Page: [1]
 
abdulsamikhan

 

Posts: 105
Joined: 12/23/2003
From: Pakistan
Status: offline

 
Hyperlink in DataGrid - 9/19/2008 14:44:39   
How to make a Database Field, Hyperlink?

I can display image in DataGrid, the picture name is stored in Access Database:

I added an ImageField Control and bound it to the database field and the image is displaying,

The problem is here where I cannot make the image hyperlink in DataGrid?

While, I was able to do the same task in Database Result Region in FrontPage2003, but how can I make the Image Hyperlink to open in full wallpaper mode, the displayed image is a thumbnail of the wallpaper.


Waiting for your response.
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: Hyperlink in DataGrid - 9/21/2008 13:27:39   
quote:

The problem is here where I cannot make the image hyperlink in DataGrid?


Oh, fun stuff indeed. :) It is not like the DRW for sure but you can do it. This is how I do it:

1) First, make sure the image is in a TemplateField and be sure to wrap the image in a Hyperlink like so:

           <asp:TemplateField HeaderText="Show Image" InsertVisible="False" SortExpression="Whatever">
                <ItemTemplate>
                    <asp:HyperLink ID="hypShowImage" runat="server" NavigateUrl='anyPageRigthHere.aspx'>
<asp:Image ID="imgMyImage" runat="server" ImageUrl="~/images/anyimage.gif" />
</asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>


2) Second, I include a hidden boundfield on the DataGrid with the image name in it like so:

<asp:BoundField DataField="ImageNameField" HeaderText="ImageNameField" SortExpression="ImageNameField" Visible="False" />

That hidden field is the easiest IMO in terms of how I can grab values specific to that row. You can do that with just about any value in a data grid or repeater-type object.

3) Then you build a Sub in the code-behind page that references each item and loads on the DataBound event like so:

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, _
 ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

        Dim myHyper As HyperLink, LinkText As String

        If e.Row.RowType <> DataControlRowType.DataRow Then
            Exit Sub
        End If

        Dim di As DataRowView = TryCast(e.Row.DataItem, DataRowView)
        If di Is Nothing Then
            Exit Sub
        End If

        myHyper = e.Row.FindControl("hypShowImage")

        LinkText = "/images/" & di("ImageNameField")
        myHyper.NavigateUrl = LinkText
        imgMyImage.ImageURL = LinkText

    End Sub


Did any of that make sense? Items 1 and 2 go in the datagrid/gridview itself and item 3 goes inside your VB.NET code (usually on a code-behind page).

The 2 keys I see is 1) addressing the grid, and 2)how to reference each item in the Grid and it's these 2 lines right here:

Dim di As DataRowView = TryCast(e.Row.DataItem, DataRowView)

and:

myHyper = e.Row.FindControl("hypShowImage")

This may have some syntax errors since I just copied one that I use and changed things on the fly but it should be pretty close. This method of grabbing a hidden boundfield works every time for me.

That help any?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to abdulsamikhan)
abdulsamikhan

 

Posts: 105
Joined: 12/23/2003
From: Pakistan
Status: offline

 
RE: Hyperlink in DataGrid - 9/21/2008 15:54:50   
Thanks rdouglass for your positive response.

Actually, i am a WYSIWYG Guy and i dont know how to hard code asp.net?

Please find another solution for me, because you have a command over coding and i really appreciate it.

And i think, Database Result Region is more powerful than DataGrid?

Please also find me the way that i can display images horizontally upto 4 or 5 and then the new row starts automatically.

Waiting for your response.

(in reply to rdouglass)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: Hyperlink in DataGrid - 9/21/2008 16:57:02   
quote:

Actually, i am a WYSIWYG Guy and i dont know how to hard code asp.net?


Sorry, I have no clue how to do this WYSIWYG. :)

quote:

And i think, Database Result Region is more powerful than DataGrid?


I disagree but that's OK. Once you become familiar wit a tool, it usually becomes more powerful than the tool you don't know how to use. Generally speaking that is.

It's like the guy who bought the chain saw because the sales rep told him he could cut 10 times more wood than with his axe. The guy comes back the next day and tells the rep that the saw was a piece of crap and wanted his money back.

The rep picks up the chain saw and startsd it up.

The guy says "Hey, what's that noise!?"

The point is that once you become familiar with a tool and know how it works, it becomes more powerful. I can do 10 times the stuff with a data grid than I could *ever* do with a DRW. The 2 should really not be compared 'cause the DRW loses easily.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to abdulsamikhan)
abdulsamikhan

 

Posts: 105
Joined: 12/23/2003
From: Pakistan
Status: offline

 
RE: Hyperlink in DataGrid - 9/22/2008 3:26:51   
Thanks again, and i very strongly agreed with you.

Ok, i have bought some ASP.NET Video Trainings and an ebook.
I will start to learn from today and i hope, i will be able to understand the coding with in 30 days.

I am a former programmer of Foxpro 2.6, COBOL, C, And Visual Basic 6. I hope, i will cover it very soon.

Many years have passed since the last time i worked on a project. But i still teach C language to my students.

Thanks again rdouglass. I will contact you after 30 days. Mark todays date. :)

(in reply to rdouglass)
rdouglass

 

Posts: 9280
From: Biddeford, ME USA
Status: offline

 
RE: Hyperlink in DataGrid - 9/22/2008 16:42:20   
quote:

I am a former programmer of Foxpro 2.6, COBOL, C, And Visual Basic 6. I hope, i will cover it very soon.


It should not take very long to come 'up-to-speed' with that background.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to abdulsamikhan)
William Lee

 

Posts: 1179
Joined: 1/25/2002
From: Singapore
Status: offline

 
RE: Hyperlink in DataGrid - 9/22/2008 18:18:59   
quote:

ORIGINAL: rdouglass


It's like the guy who bought the chain saw because the sales rep told him he could cut 10 times more wood than with his axe. The guy comes back the next day and tells the rep that the saw was a piece of crap and wanted his money back.

The rep picks up the chain saw and startsd it up.

The guy says "Hey, what's that noise!?"




Ah.. I got it now. The guy was using the chainsaw manually, hacking wood as if it was his axe. I got it now...yes I'm a bit sloow sorry roger.:)

_____________________________

William Lee

pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ
nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ





(in reply to rdouglass)
abdulsamikhan

 

Posts: 105
Joined: 12/23/2003
From: Pakistan
Status: offline

 
RE: Hyperlink in DataGrid - 9/23/2008 8:37:21   
:)

Yes, it is possible WYSIWYG and I have done it today, and it is very much flexible.

At last, I was able to do the same task manually, and Yes I have come to know that it is really a very good, powerful and flexible component.

I have been working on FrontPage for several years and I was planning to switch to Expression Web 2 and was hesitating.


Now, I have come to the point that every FP guy should move to EW 2.

I have studied the GridView tool very deeply and worked on it. And I found it very very powerful and flexible than the previous one, which I highlighted before.


Thanks to all.

(in reply to William Lee)
abdulsamikhan

 

Posts: 105
Joined: 12/23/2003
From: Pakistan
Status: offline

 
RE: Hyperlink in DataGrid - 9/23/2008 8:38:27   
Special Thanks to rdouglass for his prompt responses and positive attitude.


(in reply to abdulsamikhan)
Page:   [1]

All Forums >> Web Development >> Expression Web Help >> Hyperlink in DataGrid
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts