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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:19:26+00:00 2026-05-20T00:19:26+00:00

I have a DropDownList in a GridView EditItemTemplate. The ddl is to be populated

  • 0

I have a DropDownList in a GridView EditItemTemplate. The ddl is to be populated at runtime; options in each row may vary.

The GridView is working as desired. In non-edit mode, it binds to data. In edit mode the controls specified in the EditItemTemplate are rendered.

Question: Why can’t I FindControl on this DropDownList???
Note that I can FindControl on a Calendar control that’s also in an EditItemTemplate.

Below is the ASPX & C# code.

Thanks!!

<asp:UpdatePanel ID="UpdatePanelSelections" runat="server">
<ContentTemplate>
    <asp:GridView ID="GridViewSelections" runat="server" 
        ...

        <Columns>

            <asp:TemplateField HeaderText="Options" >
                <ItemTemplate>
                    <asp:Label ID="CurrentOption" runat="server" 
                        Text='<%# Eval("Options.OptionName") %>'>
                    </asp:Label>
                </ItemTemplate>

                <EditItemTemplate>
                    <asp:DropDownList ID="ddlOptions" runat="server" >
                    </asp:DropDownList>
                </EditItemTemplate>
                <HeaderStyle HorizontalAlign="Left" />
            </asp:TemplateField>


            <asp:TemplateField HeaderText="Date" >
                <ItemTemplate>
                    <asp:Label ID="CurrentlySelectedDate" runat="server" 
                        Text='<%# Eval("SomeDate") %>'>
                    </asp:Label>
                </ItemTemplate>

                <EditItemTemplate>
                    <asp:Calendar ID="calNewDate" runat="server" SelectedDate='<%# Bind("SomeDate") %>' VisibleDate='<%# Bind("SomeDate") %>' />
                </EditItemTemplate>
                <HeaderStyle HorizontalAlign="Left" />
            </asp:TemplateField>

        ...


    protected void GridViewSelections_RowEditing(object sender, GridViewEditEventArgs e)
   {
    // FindControl calNewDate works in GridViewSelections_RowUpdating but not in GridViewSelections_RowEditing
    Calendar calNewDate = GridViewSelectionss.Rows[e.NewEditIndex].FindControl("calNewDate") as Calendar;

    // FindControl ddlOptions doesn't work anywhere!
    DropDownList ddlOptions = GridViewSelections.Rows[e.NewEditIndex].FindControl("ddlOptions") as DropDownList;

// Looking in Cells doesn't work either
DropDownList ddlOptions2 = GridViewSelections.Rows[e.NewEditIndex].Cells[2].FindControl("ddlOptions") as DropDownList;
  • 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-20T00:19:26+00:00Added an answer on May 20, 2026 at 12:19 am

    The solution turned out to be checking that the DataItem isn’t null. Just checking for RowType and Edit flag wasn’t enough.

    protected void GridViewSelections_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if ((e.Row.RowType == DataControlRowType.DataRow) && (e.Row.RowState.HasFlag(DataControlRowState.Edit) && (e.Row.DataItem != null)))
        {
            DropDownList ddlOptions = e.Row.FindControl("ddlOptions") as DropDownList;
            ddlOptions.Items.Add(new ListItem("aaa", "1"));
            ddlOptions.Items.Add(new ListItem("bbb", "2"));
            ddlOptions.Items.Add(new ListItem("ccc", "3"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView with a DropDownList in each row. (The items in the
I have a GridView, each row has Edit button. After it's clicked, one of
I have a gridview in which every row contains a dropdownlist. I want to
I have a dropdownlist inside a gridview, that is loaded from a datasource when
I have got 2 DropDownList s on my Form and 1 GridView . I
I have tried different examples to filter a gridview by dropdownlist, but is it
I have a Gridview in which i have two templatefields of dropdownlist. I bound
I have an ASP.NET GridView with a DropDownList (in an Item Template) and a
hi I have this gridview like this. <asp:DropDownList ID=triggerDropDown runat=server AutoPostBack=true onselectedindexchanged=triggerDropDown_SelectedIndexChanged> <asp:GridView ID=myGridView
How does asp.net parse the GridView? Suppose I have defined both EditItemTemplate and ItemTemplate.

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.