Controls not recognized in the code behind file.

Discussion in 'ASP .Net' started by SWATHI ALLU, Aug 22, 2004.

  1. SWATHI ALLU

    SWATHI ALLU Guest

    Hi, I am having a problem thats really driving me nuts, i have a datagrid
    and one of the labels is initialised with a database value
    using the <%#Container.DataItem("something") %>

    now when i do this, the code behind file is not recognizing the label
    control. Any work arounds for this?

    thanks in advance

    -K
     
    SWATHI ALLU, Aug 22, 2004
    #1
    1. Advertising

  2. You didn't show your server-side code, but the asp.net code should look
    something like this:

    <asp:TemplateColumn HeaderText="Label">
    <ItemTemplate>
    <asp:Label id="Label1" runat="server"
    Text='<%#Container.DataItem("FirstName")%>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateColumn>

    Private Sub DataGrid1_ItemDataBound _
    (ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
    Handles DataGrid1.ItemDataBound
    Dim lbl As Label
    lbl = e.Item.FindControl("Label1")
    If Not IsNothing(lbl) Then
    lbl.Text = "Hello..." & lbl.Text
    End If
    End Sub


    "SWATHI ALLU" <> wrote in message
    news:eJc%...
    > Hi, I am having a problem thats really driving me nuts, i have a datagrid
    > and one of the labels is initialised with a database value
    > using the <%#Container.DataItem("something") %>
    >
    > now when i do this, the code behind file is not recognizing the label
    > control. Any work arounds for this?
    >
    > thanks in advance
    >
    > -K
    >
    >
     
    Ken Cox [Microsoft MVP], Aug 22, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    620
    Alphonse Giambrone
    Jun 28, 2003
  2. =?Utf-8?B?RGFiYmxlcg==?=

    some controls not defined in code behind file?

    =?Utf-8?B?RGFiYmxlcg==?=, Feb 7, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    550
    =?Utf-8?B?RGFiYmxlcg==?=
    Feb 7, 2006
  3. Replies:
    2
    Views:
    612
  4. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    509
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
  5. pelegk1
    Replies:
    0
    Views:
    428
    pelegk1
    Dec 13, 2007
Loading...

Share This Page