Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3402614
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:09:35+00:00 2026-05-18T05:09:35+00:00

I have a DetailsView Control, inside as a template a TextBox. I need to

  • 0

I have a DetailsView Control, inside as a template a TextBox.
I need to find out the value for a TextBox when Inserting data Event handler-, _ItemInserting.

The script does not work. Ant ideas?? Thanks

——————– WEB FORM

<asp:TemplateField HeaderText="Profile" SortExpression="ContentAuthor">
                <ItemTemplate>
                    <asp:Label ID="uxContentAuthorDisplayer" runat="server" Text='<%# Bind("ContentAuthor") %>'></asp:Label>
                </ItemTemplate>
                <InsertItemTemplate>
                    <asp:TextBox ID="uxContentAuthorInput" runat="server" Text='<%# Bind("ContentAuthor") %>'></asp:TextBox>
                </InsertItemTemplate>
            </asp:TemplateField>

——————– CODE BEHIND

          protected void uxInsertAuthor_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            //// Find control on page
            TextBox myAuthorProfile = (TextBox)uxInsertAuthorInput.FindControl("uxContentAuthorDisplayer");
            // Set a default value in Data Base if field has been left empty (DB field NOT NULL)           
            if (string.IsNullOrEmpty(myAuthorProfile.Text))
            {
                string myAllert = "Field is NULL";
            }
            else
            {
                string myAllet = "Field is NOT NULL";
            }          
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:09:36+00:00Added an answer on May 18, 2026 at 5:09 am

    Try using the FindControl method of your TemplateField container control (the DetailsView). For example, if your DetailsView is named “MyControl” try

    //// Find control on page
    TextBox myAuthorProfile = (TextBox)MyControl.FindControl("uxContentAuthorInput");
    

    Please Note

    You are using the ID of the Label control in your FindControl method and you are trying to cast it to a TextBox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DetailsView with a TextBox bound to a DateTime column. The value
I have a DetailsView, I need get the value specifield in DataKeyNames UserId (a
I have a DetailsView with a TextBox and I want the input data be
I currently have a DetailsView in ASP.NET that gets data from the database based
I have a asp.net detailsview control on a page. I've noticed that it always
I have an ObjectDataSource that I'm binding to a DetailsView control. I have the
I am using a DetailsView control. Here I have both edit and delete buttons.
I have a page where I use two ASP DetailsView controls to render data
I have a TemplateField in a DetailsView and its input should be one of
I have a basic test web form with a DataList and a DetailsView and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.