Changing Gridview Value

Posted on 2011-10-12
Last Modified: 2012-05-12

I have a gridview control.  This has several columns and multiple rows.

I’d like to accomplish the following.  Take the value of column 4 and pass it into a function which returns a value and then displays that in the original cell.
This is to be done for each row.

I thought I could do this like this but this gives an Object reference not set to an instance of an object error:

    Protected Sub GV_All_Actions_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GV_All_Actions.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim lblActioner As Label = DirectCast(GV_All_Actions.FindControl("lbl_actioner"), Label)
            lblActioner.Text = callFunction(lblActioner.Text.ToString())
        End If
    End Sub

Any suggestions?
Question by:andyw27
    LVL 17

    Accepted Solution


    e.Row.FindControl("SqlDataSource1") instead of GV_All_Actions.FindControl("lbl_actioner")

    LVL 17

    Expert Comment

    Replace SqlDataSource1 with lbl_actioner

    Author Comment

    Cheers worked like a charm.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now