Archive Page 2
Setting the NavigateUrl property of a hyperlink control in gridview is very easy. But what if you want to pass the value of a specific field in your gridview as a url parameter of your hyperlink control? Well here’s how to do it.
Let say we have a customer list in a gridview and an edit link on the first column and customer id, name, and address on the following columns shown on the image below. Now we want to set the url of our edit link to customerEdit.aspx and at the same time pass the value of the customer id column as a url parameter.

To do this, create a template field for your first column and create a hyperlink control for your item template (See code below). Don’t forget to set the ID of this control because we will use it as reference. You will notice that we didn’t set the value of its navigateUrl property yet, it is because we want to set it row by row while we populate the gridview.
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID=”EditLink” Text=”Edit…” runat=”server” />
</ItemTemplate>
</asp:TemplateField>
If you want your link to be an image instead of a text, you could always use the ImageUrl property of the hyperlink control.
<asp:HyperLink ID=”EditLink” ImageUrl=”~/Image/edit.png” runat=”server” />
In this example, my image “edit.png” is located inside the Image folder of my web application root directory.
Now lets move on to the next step, the setting of NavigateUrl property. We will set this property in each row while our datasource populates our gridview. To do this, we will be writing our code in the RowDataBound event of our gridview.
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As _ System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim myLink As HyperLink = CType(e.Row.FindControl(”EditLink”), HyperLink)
myLink.NavigateUrl = “CustomerEdit.aspx?CustomerId=” & e.Row.Cells(1).Text
End If
End Sub
The hyperlink control that we created will only be available on datarows, that’s why we have to check the rowtype of each row before we proceed on setting the hyperlink’s navigateUrl property. If we did not put the line If e.Row.RowType = DataControlRowType.DataRow, we will end up searching for a hyperlink control that is not available on the given row.
After we checked the rowtype and confirmed that the row is a datarow, we then now create a hyperlink variable called “myLink”. We use the code CType(e.Row.FindControl(”EditLink”), HyperLink) to search for the control on the current row with ID=”EditLink” and convert it to a hyperlink type control. We then set this control as the value of our hyperlink variable called “myLink”.
We now have access on a hyperlink control in a given row through “myLink” variable. In this example, we set its navigateUrl property to customerEdit.aspx and pass the value of customer id located in the 2nd column of our gridview as a url parameter called “customerID”.
Brain Test
I created my own account in tickle and got interested in their Brain Test. I was really impressed at my own result, never thought my left and right brain are perfectly working together fair and square. Hehe! It’s really fun you should try it.
Richard, you are Balanced-brained
That means you are able to draw on the strengths of both the right and left hemispheres of your brain, depending upon a given situation.
When you need to explain a complicated process to someone, or plan a detailed vacation, the left hemisphere of your brain, which is responsible for your ability to solve problems logically, might kick in. But if you were critiquing an art opening or coming up with an original way to file papers, the right side of your brain, which is responsible for noticing subtle details in things, might take over.
While many people have clearly dominant left- or right-brained tendencies, you are able to draw on skills from both hemispheres of your brain. This rare combination makes you a very creative and flexible thinker.
The down side to being balanced-brained is that you may sometimes feel paralyzed by indecision when the two hemispheres of your brain are competing to solve a problem in their own unique ways.
Problem: I customized my gridview and created a set of boundfield columns. Now, I need to make one of these boundfields be clickable or some sort of hyperlink.
Solution: Create a TemplateField and a hyperlink control in your ItemTemplate.
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="Hyperlink1" runat="server"
Text='<%# Bind("FieldName") %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
In this example, the HyperLink Text property is binded to a specific field from the datasource used by the gridview. In this way you could now have a clickable BoundField in your gridview. Just modify the NavigateUrl property of the HyperLink control for its navigation functionality.
DIV vs. TABLES
Tables were not created for web layout or positioning. Tables were created to provide structure to data. They were created to contain tabular data. Though the early html standard uses table for layout purposes, yet it is not the best tool for it. The main disadvantage of using tables to layout a page is its complex code(specially if nested tables are present) and limited attributes.
Div on the other hand are very much flexible. You can position the div anywhere on your page and you can position anything and anywhere on it. Unlike tables which can only be positioned on LEFT, CENTER, or RIGHT side of your page. In short, Div has no limitations when it comes to positioning, resizing, and designing.
I found a site that teaches CSS layouting (page layout using div) that is very easy to understand and easy to implement. Very helpful for both the novice and the css veteran. Check it at glish.com.
Beautiful Things
I was on roofdeck of a 33-floor-building while I am enjoying another wonderful manila bay sunset. The sky is a gradient of blue and red and a small strip of clouds are there to make the view more beutiful. It was around 5pm and was already tired from work. But with this kind of panoramic view: the sky, the sunset, the clouds, the ocean, and mountains, oh God really loves us. He made it all for us to enjoy.
I looked towards the ground and saw busy streets, people rushing through traffic, traffics blowing horn at each other, toxic. Made me think if only they could see the sunset from where I am standing at, Im sure they would call it a day. I wonder why so many people fail to put God above all. Maybe because they’re too busy to look at wonderful things that God gave us.


