Welcome to Dream.In.Code
Become an Expert!

Join 150,239 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,358 people online right now. Registration is fast and FREE... Join Now!




GidView RowDataBound Problem...

 
Reply to this topicStart new topic

GidView RowDataBound Problem...

dev1910
4 Dec, 2007 - 02:28 AM
Post #1

New D.I.C Head
*

Joined: 4 Dec, 2007
Posts: 1


My Contributions
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 :

CODE

    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

*Mod Edit: Please use code tags for your code: code.gif

This post has been edited by PsychoCoder: 4 Dec, 2007 - 06:12 AM


Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

ketan_patel19
RE: GidView RowDataBound Problem...
4 Dec, 2007 - 05:19 AM
Post #2

New D.I.C Head
*

Joined: 4 Dec, 2007
Posts: 3


My Contributions
u enter 1 record in your database then u try.......
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: GidView RowDataBound Problem...
4 Dec, 2007 - 06:13 AM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
As kentan pointed out do you you have any records in the table you are querying.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 06:17AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month