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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:07:12+00:00 2026-06-12T05:07:12+00:00

I’m using an asp.net 4 web site project (C#) in VS2008 and I have

  • 0

I’m using an asp.net 4 web site project (C#) in VS2008 and I have a FormView with ItemUpdated event:

<asp:FormView ID="FormView1" runat="server" DataSourceID="ds1" OnItemUpdated="FormView1_ItemUpdated">
    <EditItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("col1") %>' />
    </EditItemTemplate>
</asp:FormView>

protected void FormView1_ItemUpdated(object sender, EventArgs e)
{
    FormView1.DataBind();  // adding this line even doesn't help
    TextBox box = FormView1.FindControl("TextBox1") as TextBox;
    box.Enabled = false;
}

But I can’t figure out, why an extra “FormView1.DataBind()” or Render(?) happens AFTER the ItemUpdated event. The result is that my code in the ItemUpdated event gets like “overwritten” and the TextBox1 doesn’t get disabled.

When I set a breakpoint to the last line “box.Enabled = false;” then I see that after the ItemUpdated event it jumps to the aspx page again and steps through the TextBoxes.

Disabling this TextBox1 from another GridView1_SelectedIndexChanged works fine.

Is there any way to see the “current lifecycle progress” in debugging?

EDIT:

To clarify the reasoning…
I have a GridView1 where selecting the item populates the abovementioned FormView1. The point is that I need to disable some of the TextBoxes in the FormView1 based on, for example, user access levels.
Selecting the item from GridView1 disables the TextBox1 just fine, but when I click the Update button on the FormView1 then all TextBoxes are enabled, even if I see in the debugger code running through the GridView1_SelectedIndexChanged() function. And after I re-select the gridview item, the correct TextBoxes are disabled again.
Using even this code:

<asp:FormView ID="FormView1" runat="server" DataSourceID="ds1" DefaultMode="Edit" OnItemUpdated="FormView1_ItemUpdated">
    <EditItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("col1") %>' />
        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("col2") %>' />
        <asp:Button ID="Btn1" runat="server" CommandName="Update" Text="Update" />
    </EditItemTemplate>
</asp:FormView>

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (UserAccess() == false) {
        TextBox box2 = FormView1.FindControl("TextBox2") as TextBox;
        box2.Enabled = false;
    }
}
protected void FormView1_ItemUpdated(object sender, EventArgs e)
{
    GridView1_SelectedIndexChanged(sender, e);
}

Maybe I should disable my Textboxes via another event?

  • 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-12T05:07:13+00:00Added an answer on June 12, 2026 at 5:07 am

    This doesn’t make sense, please explain more about why you are trying to disable the TextBox, have you just left the ItemTemplate off in your question? or is it actually missing? if it’s missing why?

    The TextBox is in the FormView’s EditItemTemplate, so will only be visible when the FormView is in edit mode. After clicking update or cancel the TextBox will no longer be rendered, and the ItemTemplate is rendered instead. So there should be no need to set the TextBox to be disabled.

    EDIT

    Ok since you edited your question. You need to use the OnDataBound event of the FormView, which occurs at the end of binding, and disable your TextBoxes at that point.

    aspx

    <asp:FormView ID="FormView1" runat="server" DataSourceID="ds1" 
        OnDataBound="FormView1_DataBound">
        <EditItemTemplate>
            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("col1") %>' />
        </EditItemTemplate>
    </asp:FormView>
    

    aspx.cs

    protected void FormView1_DataBound(object sender, EventARgs e)
    {
        if (UserAccess() == false) {
            TextBox box2 = FormView1.FindControl("TextBox2") as TextBox;
            box2.Enabled = false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have thousands of HTML files to process using Groovy/Java and I need to
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't

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.