Link to home
Start Free TrialLog in
Avatar of scm0sml
scm0sml

asked on

cant find label in gridview

I have the gridview below.

In my code behind I then have:
 Protected Sub gvInvoiceQueries_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvInvoiceQueries.RowDataBound
        Dim invoice As Invoice = Nothing
        Dim lblPaymentType As Label = Nothing

        Try
            Select Case e.Row.RowType
                Case DataControlRowType.DataRow
                    lblPaymentType = CType(e.Row.FindControl("lblPaymentType"), Label)

The label is nothing so isn't being found.

What am I doing wrong?
<asp:GridView  ID="gvInvoiceQueries" runat="server" CssClass="gridviewheader" AutoGenerateColumns="False" > 
     <Columns>
            <asp:TemplateField HeaderText="Query Type">     
                <ItemTemplate>
                    <asp:Label ID="lblQueryType" runat="server" Text='<%#Bind("QueryType.Description")%>'></asp:Label>                                        
                </ItemTemplate>                                 
            </asp:TemplateField> 
            <asp:TemplateField HeaderText="Payment Type">     
                <ItemTemplate>
                    <asp:Label ID="lblPaymentType" runat="server" Text=''></asp:Label>                                        
                </ItemTemplate>                                 
            </asp:TemplateField>

Open in new window

Avatar of robasta
robasta
Flag of Zimbabwe image

Avatar of scm0sml
scm0sml

ASKER

i dont need to loop through like that there is a way of doing it as i am I just can't remember the exact syntax or logic............

Your page does mention the find control which is how I am doing it but doesn't go into much detail.
ASKER CERTIFIED SOLUTION
Avatar of robasta
robasta
Flag of Zimbabwe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial