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

  • Home
  • SEARCH
  • 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 9005085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:03:23+00:00 2026-06-16T01:03:23+00:00

Basically, I am trying to put validation control in of Listview. But, I am

  • 0

Basically, I am trying to put validation control in of Listview. But, I am not able to specify ControlToValidate = “grpNameTextBox”.

I tried to put

((RequiredFieldValidator)ListView1.FindControl("RequiredFieldValidator1")).ControlToValidate = ((TextBox)ListView1.FindControl("grpNameTextBox")).ID;

in different Events, but not able to do it.

Afterwards, I deleted Validation Control, and put simple Label. Then in ‘ItemInserting’ event I put this code :

protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
    {
        TextBox t1 = (TextBox)ListView1.FindControl("grpNameTextBox"); // Getting Null Exception here
        if (t1.Text.Trim() == null)
        {
            throw new System.Exception("Field cannot be empty");


        }
    }

But getting “Object reference not set to an instance of an object.” error.
Can any one tell me, where I am wrong?

.aspx part is given below :

<InsertItemTemplate>
        <tr style="">
            <td>
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                    Text="Insert"  />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Clear" />
            </td>
            <td>
                &nbsp;</td>
            <td>
                <asp:TextBox ID="grpNameTextBox" runat="server" Text='<%# Bind("grpName") %>' />
                <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
            </td>
        </tr>
    </InsertItemTemplate>

Thanks.

  • 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-06-16T01:03:24+00:00Added an answer on June 16, 2026 at 1:03 am

    TextBox txt_btn = (TextBox)e.Item.FindControl(“grpNameTextBox”);

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

Sidebar

Related Questions

Basically I'm Trying to put out on the Textbox inside the Shared Function, But
Basically i have a problem with this timer program I am trying to put
I'm basically trying to make my js and css files dynamic. I've tried a
Basically, I am trying to put a semi-transparent div over an image to serve
Hey, so basically I have this issue, where I'm trying to put an equation
Basically I am trying to put a button in my app which will warn
Basically i've got a web service that i'm trying to put some kind of
My terminology is probably way off here but basically I'm trying to pass multiple
Basically, I am trying to put overlap corners behind the #page_container on my site,
Have to erase some of the details of this, but basically I'm trying to

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.