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 553363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:35:50+00:00 2026-05-13T11:35:50+00:00

I have a list view with a label that shows Step #x, another label

  • 0

I have a list view with a label that shows “Step #x”, another label with the instructions, and then 2 linkbuttons for editing or deleting. At the footer of the ListView is another button “Add New Step” which opens up an empty TextBox and two buttons to save and cancel. I would also like it to increment the label, but I can seem to find the control in the code behind to change it’s text. How do I do this?

Here’s the asp markup:

<asp:ListView ID="lvSteps" runat="server" DataSourceID="ldsProcessStep" DataKeyNames="ID" InsertItemPosition="None">
    <LayoutTemplate>
        <div><asp:PlaceHolder ID="itemPlaceholder" runat="server" /></div>
        <asp:Button ID="btnAddNewStep" runat="server" Text="Add New Step" OnClick="btnAddNewStep_Click" />
    </LayoutTemplate>
    <ItemTemplate>
        <table width="100%">
            <tr>
                <td>
                    <asp:label runat="server" Text='<%# Eval( "StepNumber", "Step #{0}" ) %>' Width="75px" style="font-size:medium; font-weight:bold;" />
                </td>
                <td>
                    <div style="text-align:left; width:350px;">
                        <asp:label runat="server" Text='<% #( Eval("Instruction") ) %>' style="font-size:85%;" />
                    </div>
                </td>
                <td>
                    <div style="width:50px;">
                        <div><asp:LinkButton Text="Edit" runat="server" CommandName="Edit" style="font-size:75%;" /></div>
                        <div style="margin-top:5px;"><asp:LinkButton Text="Delete" runat="server" style="font-size:75%;" OnClientClick='<%# CreateConfirmation( Eval("StepNumber") ) %>' /></div>
                    </div>
                </td>
            </tr>
        </table>
        <hr style="width:90%; margin-left:20px;" />
    </ItemTemplate>
    <InsertItemTemplate>
        <table width="100%">
            <tr>
                <td>
                    <asp:Label ID="lblNewStepNumber" runat="server" Width="75px" Text="????" style="font-size:medium; font-weight:bold;" />
                </td>
                <td>
                    <div style="text-align:left; width:350px;">
                        <asp:TextBox ID="txtInstruction" runat="server" TextMode="MultiLine" Rows="3" Width="100%" Text='<%# Bind("Instruction") %>' style="font-size:85%;" />
                    </div>
                </td>
                <td>
                    <div style="width:50px;">
                        <div><asp:LinkButton ID="btnInsert" Text="Save" runat="server" CommandName="Insert" style="font-size:75%;" /></div>
                        <div style="margin-top:5px;"><asp:LinkButton ID="lnkCancelInsert" Text="Cancel" runat="server" CommandName="Cancel" OnClick="btnCancelInsert_Click" style="font-size:75%;" /></div>
                    </div>
                </td>
            </tr>
        </table>
    </InsertItemTemplate>
</asp:ListView>

And some attempted code:

public void btnAddNewStep_Click( object sender, EventArgs e )
{
    lvSteps.InsertItemPosition = InsertItemPosition.LastItem;
    lvSteps.FindControl( "btnAddNewStep" ).Visible = false;

    //Cannot find control

    //lvSteps.FindControl( "lblNewStepNumber" ).Text = "doesn't work"

    //Label lbl = (Label)lvSteps.FindControl( "lblNewStepNumber" );
    //lbl.Text = "Doesn't work"'
}
  • 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-13T11:35:50+00:00Added an answer on May 13, 2026 at 11:35 am

    I believe lvSteps has a reference to InsertItem (as in lv.InsertItem.FindControl(“”)), which you can use to find controls in the insert template. For lvSteps.FindControl finds controls created in the layout template. I think ItemDataBound or ItemCreated may also fire for the insert item, but I’m not 100% sure about that.

    Property definition is available here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.listview.insertitemtemplate.aspx

    HTH.

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

Sidebar

Related Questions

Afternoon all. I have a drop down list in my view <div class=editor-label> @Html.LabelFor(model
In my application, I have list view. Selecting another item in it, triggers an
I have a list view with many rows and have it set so that
I have a list view that displays a collection of items, each item has
I have list view and its adapter stored as global variables. I am not
I have a list view binded to a data source. How can I enable
I have a list view with 10 columns and I want each row to
I have a list view which is bound to a DataTable source. The sorting
I have a list view comprised of the following: // Add column headers for
I have a list view item which has a button and displays properties on

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.