scm0sml
asked on
cant find label in gridview
I have the gridview below.
In my code behind I then have:
Protected Sub gvInvoiceQueries_RowDataBo und(ByVal sender As Object, ByVal e As System.Web.UI.WebControls. GridViewRo wEventArgs ) Handles gvInvoiceQueries.RowDataBo und
Dim invoice As Invoice = Nothing
Dim lblPaymentType As Label = Nothing
Try
Select Case e.Row.RowType
Case DataControlRowType.DataRow
lblPaymentType = CType(e.Row.FindControl("l blPaymentT ype"), Label)
The label is nothing so isn't being found.
What am I doing wrong?
In my code behind I then have:
Protected Sub gvInvoiceQueries_RowDataBo
Dim invoice As Invoice = Nothing
Dim lblPaymentType As Label = Nothing
Try
Select Case e.Row.RowType
Case DataControlRowType.DataRow
lblPaymentType = CType(e.Row.FindControl("l
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>
use recursion, like here: http://www.devtoolshed.com/content/find-control-templatefield-programmatically
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.
Your page does mention the find control which is how I am doing it but doesn't go into much detail.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.