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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:51:10+00:00 2026-05-25T15:51:10+00:00

Ok so i have a DetailsView like so… <asp:DetailsView DataSourceID=sqldsNewItem CssClass=marginLeftRightBottom10px DefaultMode=Insert FieldHeaderStyle-CssClass=dwHeader GridLines=None

  • 0

Ok so i have a DetailsView like so…

<asp:DetailsView DataSourceID="sqldsNewItem" CssClass="marginLeftRightBottom10px"
                DefaultMode="Insert" FieldHeaderStyle-CssClass="dwHeader" GridLines="None" ID="dwNewItem"
                runat="server">
                <Fields>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <h1>
                                Item Name:</h1>
                        <p>
                            The name of the item.</p>
                    </HeaderTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox runat="server" ID="tbItemName"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <h1>
                            Item Description:</h1>
                        <p>
                            The description of the item.</p>
                    </HeaderTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox runat="server" ID="tbItemDescription"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <h1>
                            Item Image:</h1>
                        <p>
                            The image of the item.</p>
                    </HeaderTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox runat="server" ID="tbItemImage"></asp:TextBox>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <h1>
                            Item Type:</h1>
                        <p>
                            Specifies the item type.</p>
                    </HeaderTemplate>
                    <InsertItemTemplate>
                        <asp:DropDownList OnSelectedIndexChanged="ddlItemTypes_SelectedIndexChanged" DataTextField="itemType" DataValueField="typeId"
                            DataSourceID="sqldsTier1Category" ID="ddlItemTypes" runat="server">
                        </asp:DropDownList>
                        <asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:myDbConnection%>" ID="sqldsTier1Category"
                            runat="server" SelectCommand="dbo.getItemCategories" SelectCommandType="StoredProcedure">
                        </asp:SqlDataSource>
                    </InsertItemTemplate>
            </Fields>
        </asp:DetailsView>

Now as you can see, one of the DroDownLists has an event:

OnSelectedIndexChanged="ddlItemTypes_SelectedIndexChanged"

But for some reason, it isnt firing when i select a new item from the DropdownList. Here is how i handled it in the codebehind:

protected void ddlItemTypes_SelectedIndexChanged(object sender, EventArgs e)
{
    DropDownList ddl = (DropDownList)sender;
    if (ddl.SelectedItem.Text.ToLower() == "equipment")
    {
        TextBox tb = (TextBox)FindControl("tbItemBonusStr");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemBonusAgl");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemBonusMP");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemBonusHP");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemBonusMana");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemBonusIni");
        tb.Enabled = true;

        tb = (TextBox)FindControl("tbItemPermanentStr");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemPermanentAgl");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemPermanentMP");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemRestoresHp");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemRestoresMana");
        tb.Enabled = false;
    }

    else if (ddl.SelectedItem.Text.ToLower() == "consumable")
    {
        TextBox tb = (TextBox)FindControl("tbItemBonusStr");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemBonusAgl");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemBonusMP");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemBonusHP");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemBonusMana");
        tb.Enabled = false;
        tb = (TextBox)FindControl("tbItemBonusIni");
        tb.Enabled = false;

        tb = (TextBox)FindControl("tbItemPermanentStr");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemPermanentAgl");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemPermanentMP");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemRestoresHp");
        tb.Enabled = true;
        tb = (TextBox)FindControl("tbItemRestoresMana");
        tb.Enabled = true;
    }
}

Now i know that these controls are created at runtime, but shouldnt events still work for them?

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-05-25T15:51:11+00:00Added an answer on May 25, 2026 at 3:51 pm

    You need to set Autopostback=”true” on your dropdown.

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

Sidebar

Related Questions

I have a DetailsView like this: <asp:DetailsView ID=detailsView1 runat=server DataSourceID=edsdetailsView AutoGenerateRows=False CssClass=pretty-table> <Fields> <asp:TemplateField
I have a control that look something like this: <asp:DetailsView ID=dvUsers runat=server DataSourceID=odsData DataKeyNames=Id>
<asp:DetailsView ID=DetailsView1 runat=server AutoGenerateRows=False DataSourceID=TimeEntriesDataSource RowStyle-VerticalAlign=Top DefaultMode=Insert HeaderStyle-HorizontalAlign=Center BackColor=White BorderColor=#336666 BorderStyle=Double BorderWidth=3px CellPadding=4 OnItemInserted=DetailsView1_ItemInserted
Say you have something like an ASP.NET ASP:DetailsView to show and edit a single
My problem is like this: In ASP DetailsView component we have three different EventArgs
I currently have a DetailsView in ASP.NET that gets data from the database based
In my asp.net application,I want to use the detailsview to show/insert/update data in the
I have a page where I use two ASP DetailsView controls to render data
Currently I have a ListView (using the Details View). I would like to implement
I have a DetailsView with a number of textboxes setup with RequiredFieldValidators. The code

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.