Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Hi,

I'm having problems returning the text value of a label that is databound in a parent <code>gridview. I need to use the text value to assign it to a select parameter in a child <code>gridview but it keeps throwing a null reference. Can anyone see a problem with the following code?

I have a parent gridview called browsetopicsview, a child gridview called NestedPostCount a databoud label called CreatedBy which is what i want in the where clause of the child select statment.  

 Protected Sub BrowseTopicsView_RowDataBound(ByVal sender As Object, 
               ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) 
                                    Handles BrowseTopicsView.RowDataBound
        Dim s As SqlDataSource = CType(e.Row.FindControl("NestedPostCount"),
                                                                 SqlDataSource)
        Dim g As New Label
        g = CType(FindControl("CreadtedBy"), Label)
        Try
            s.SelectParameters(0).DefaultValue = g.Text
        Catch
            MsgBox("An error has occured in the database,
                         please try again later")
        End Try
End Sub

 Thanks,   

Chris  

 

Posted
Updated 26-Nov-09 9:50am
v3

1 solution

Maybe "CreadtedBy" is spelled correctly on the property assignment?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900