•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,772 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3861 | Replies: 1
![]() |
•
•
Join Date: Dec 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hello frenz,
I am trying to modify the templateField itemized hyperlink on my GridView.
My problem is ,
I have 3 types of status, 'KIV','Complete'&'Incomplete'.
I must display 'KIV' in Red color font with its coresponding linkA.
As for 'Complete', it has to be in 'Green' and matched to linkB.
the 'Incomplete' status should be shown in Black color font and linked it with linkC.
To do this, i used the following method :
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 hLink As String = DataBinder.Eval(e.Row.DataItem, "STATUS").ToString()
If hLink.Equals("KIV") Then
Dim hLnk As HyperLink = CType(e.Row.FindControl("UW Status"), HyperLink)
hLnk.ForeColor = Drawing.Color.Red
hLnk.NavigateUrl = "linkA.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
ElseIf hLink.Equals("Complete") Then
Dim hLnk As HyperLink = CType(e.Row.FindControl("UW Status"), HyperLink)
hLnk.ForeColor = Drawing.Color.Green
hLnk.NavigateUrl = "linkB.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
Else
Dim hLnk As HyperLink = CType(e.Row.FindControl("UW Status"), HyperLink)
hLnk.ForeColor = Drawing.Color.Black
hLnk.NavigateUrl = "linkC.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
End If
End If
End Sub
Problem is, im getting error when i execute the web site.The error description is 'Object reference not set to an instance of an object.'
Plz someoen help me sort it out what is the error with my coding.Realy appreciated.
thanks & regards dev
I am trying to modify the templateField itemized hyperlink on my GridView.
My problem is ,
I have 3 types of status, 'KIV','Complete'&'Incomplete'.
I must display 'KIV' in Red color font with its coresponding linkA.
As for 'Complete', it has to be in 'Green' and matched to linkB.
the 'Incomplete' status should be shown in Black color font and linked it with linkC.
To do this, i used the following method :
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 hLink As String = DataBinder.Eval(e.Row.DataItem, "STATUS").ToString()
If hLink.Equals("KIV") Then
Dim hLnk As HyperLink = CType(e.Row.FindControl("UW Status"), HyperLink)
hLnk.ForeColor = Drawing.Color.Red
hLnk.NavigateUrl = "linkA.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
ElseIf hLink.Equals("Complete") Then
Dim hLnk As HyperLink = CType(e.Row.FindControl("UW Status"), HyperLink)
hLnk.ForeColor = Drawing.Color.Green
hLnk.NavigateUrl = "linkB.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
Else
Dim hLnk As HyperLink = CType(e.Row.FindControl("UW Status"), HyperLink)
hLnk.ForeColor = Drawing.Color.Black
hLnk.NavigateUrl = "linkC.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
End If
End If
End Sub
Problem is, im getting error when i execute the web site.The error description is 'Object reference not set to an instance of an object.'
Plz someoen help me sort it out what is the error with my coding.Realy appreciated.
thanks & regards dev
•
•
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation:
Rep Power: 11
Solved Threads: 102
Does that say what line of code that's happening on?
I can see that you probably just need to instantiate the HyperLink just once:
Now, if you have that, then what might be going on is that it's not finding a control in your templateField called "UW Status". Alternatively, you might need to use
e.Row.Cells[x].FindControl("UW Status")
where x is the index of the column that you know your templateField is located.
I can see that you probably just need to instantiate the HyperLink just once:
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 hLink As String = DataBinder.Eval(e.Row.DataItem, "STATUS").ToString()
Dim hLnk As HyperLink = CType(e.Row.FindControl("UW Status"), HyperLink)
If hLink.Equals("KIV") Then
hLnk.ForeColor = Drawing.Color.Red
hLnk.NavigateUrl = "linkA.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
ElseIf hLink.Equals("Complete") Then
hLnk.ForeColor = Drawing.Color.Green
hLnk.NavigateUrl = "linkB.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
Else
hLnk.ForeColor = Drawing.Color.Black
hLnk.NavigateUrl = "linkC.asp?AppId=" + DataBinder.Eval(e.Row.DataItem, "APP_ID").ToString()
End If
End If
End SubNow, if you have that, then what might be going on is that it's not finding a control in your templateField called "UW Status". Alternatively, you might need to use
e.Row.Cells[x].FindControl("UW Status")
where x is the index of the column that you know your templateField is located.
Alex Cavnar, aka alc6379
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: Diaplay help message(Popup)
- Next Thread: Hi guys please clear my doubt.



Linear Mode