Hello,
I am having an issue with the FindControl looking for a textbox in the Insert mode.
I am doing this in the ItemCommand.

I have a "Copy" button that is on the ReadOnly mode. I then change over to the Insert mode and start working with filling in some of the data that is not bound (splitting the date and time into their own fields).

I check to see if the CurrentMode is in Insert mode before I do the FindControl. Here is my code.

        Dim tbCallBackDate As TextBox

        If fvMailout.CurrentMode <> FormViewMode.ReadOnly Then
            If e.CommandName = "Cancel" Then
                GoBack()
            End If

            tbCallBackDate = fvMailout.Row.FindControl("CallBackDateTextBox")

            If IsDate(tbCallBackDate.Text) Then
                If tbCallBackDate.Text = dtDefault Then
                    tbCallBackDate.Text = Nothing
                End If
            Else
                tbCallBackDate.Text = Nothing
            End If
            Session("OrigCallBackDate") = tbCallBackDate.Text
        End If

Here is the Textbox Coding:

<asp:TextBox ID="CallBackDateTextBox" runat="server" 
CssClass="Textbox" TabIndex="17" Text='<%# Bind("CallBackDate", "{0:d}") %>' 
Visible="False" Width="100px" AutoPostBack="True" />

Any help would be greatly appreciated.
Eddi Rae

I found the issue. I had this in the ItemCommand. Once I moved this code to the Page's PreRenderComplete, the item was found.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.