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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:11:09+00:00 2026-05-20T22:11:09+00:00

Attaching the code below – its a simple code that just initializes the dropdown

  • 0

Attaching the code below – its a simple code that just initializes the dropdown (calling ddl.Clear()) and adds an item with text “select” which has value “-1”.

Filldropdowns(ddl) are methods that get specific data and populate it into the dropdown method. The methods individually work fine outside the gridview on normal dropdownlists.

What happens is this eventhandler gets called more than once for each gridview row. As an end result, the dropdowns contain double the values they are supposed to contain (the complete set of values just get repeated).

Anyone knows why this is happening? Turning off appenddatabounditems is not an option because i need the items to be appended below the “select”.

Strange thing is, when I debug, even on the second time call for the same row, it shows that the dropdownvalues contain zero items and then contains the required number of items. But by the time I reach grdAccountsMapping_DataBound() handler, it shows twice the number of items.

public void grdAccountsMapping_RowCreated(object sender, GridViewRowEventArgs e)
{
    GridViewRow row = e.Row;

    if (row.RowType == DataControlRowType.DataRow)
    {
        DropDownList ddlGrdFeeFormat = (DropDownList)row.FindControl("ddlFeeFormat");
        DropDownList ddlGrdTransactionMode = (DropDownList)row.FindControl("ddlTransactionMode");
        DropDownList ddlGrdFeeParticular = (DropDownList)row.FindControl("ddlFeeParticular");
        DropDownList ddlGrdCompany = (DropDownList)row.FindControl("ddlCompany");
        DropDownList ddlGrdAccounts = (DropDownList)row.FindControl("ddlAccounts");
        DropDownList ddlGrdFeeBook = (DropDownList)row.FindControl("ddlFeeBook");

        InitializeDropdown(ddlGrdFeeBook);
        InitializeDropdown(ddlGrdFeeFormat);
        InitializeDropdown(ddlGrdTransactionMode);
        InitializeDropdown(ddlGrdFeeParticular);
        InitializeDropdown(ddlGrdCompany);

        getDDLValues.FillFeeBooks(ddlGrdFeeBook);
        getDDLValues.FillFeeFormats(ddlGrdFeeFormat);
        getDDLValues.FillPaymentModes(ddlGrdTransactionMode);
        getDDLValues.FillFeeParticulars(ddlGrdFeeParticular);
        getDDLValues.FillAccountingCompanies(ddlGrdCompany);
    }
}

The aspx page grid definition looks like this

<asp:GridView CssClass="Grid" ID="grdAccountsMapping" runat="server" Width="98%"
EmptyDataText="No records found in this section" EmptyDataRowStyle-Height="40px"
AutoGenerateColumns="False" AccessKey="2" DataKeyNames="FAM_MAP_ID" OnRowCommand="grdAccountsMapping_RowCommand"
OnRowCreated="grdAccountsMapping_RowCreated" OnDataBound="grdAccountsMapping_DataBound"
Visible="false">
<AlternatingRowStyle CssClass="alternateGridItem" HorizontalAlign="Left" />
<RowStyle CssClass="gridItem" HorizontalAlign="Left" />
<EmptyDataRowStyle CssClass="gridItem" HorizontalAlign="Center" Font-Bold="True"
    ForeColor="Red" Height="40px" VerticalAlign="Middle" />
<HeaderStyle CssClass="tabledarklabel" />
<FooterStyle CssClass="Grid_Footer" />
<Columns>
    <asp:TemplateField HeaderText="Fee Book">
        <ItemTemplate>
            <asp:DropDownList ID="ddlGrdFeeBook" CssClass="dropdownwidth3" runat="server" AppendDataBoundItems="True">
            </asp:DropDownList>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
        <HeaderStyle Width="5%" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Fee Format">
        <ItemTemplate>
            <asp:DropDownList ID="ddlGrdFeeFormat" CssClass="dropdownwidth3" runat="server" AppendDataBoundItems="True">
            </asp:DropDownList>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
        <HeaderStyle Width="5%" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Transaction Mode">
        <ItemTemplate>
            <asp:DropDownList ID="ddlGrdTransactionMode" CssClass="dropdownwidth3" runat="server"
                AppendDataBoundItems="True" >
            </asp:DropDownList>
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Fee Particulars">
        <ItemTemplate>
            <asp:DropDownList ID="ddlGrdFeeParticular" CssClass="dropdownwidth3" runat="server"
                AppendDataBoundItems="True">
            </asp:DropDownList>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
        <HeaderStyle Width="5%" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Company">
        <ItemTemplate>
            <asp:DropDownList ID="ddlGrdCompany" CssClass="dropdownwidth3" runat="server" AppendDataBoundItems="True">
            </asp:DropDownList>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
        <HeaderStyle Width="5%" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Account">
        <ItemTemplate>
            <asp:DropDownList ID="ddlGrdAccounts" CssClass="dropdownwidth3" runat="server" AppendDataBoundItems="True">
            </asp:DropDownList>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
        <HeaderStyle Width="5%" />
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Active">
        <ItemTemplate>
            <asp:CheckBox ID="chkActive" runat="server" />
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" />
        <HeaderStyle Width="5%" />
    </asp:TemplateField>
</Columns>
<PagerSettings Visible="False" />
<PagerStyle BorderStyle="None" />
</asp:GridView>

The other methods used just retrieve a dataset for the data needed, assign it to the datasourceo of the dropdown and then bind it to the dropdownlist control. Those methods work fine on dropdowns outside the grid, and I have unit tested them – so I am sure the problem is not there.

  • 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-20T22:11:10+00:00Added an answer on May 20, 2026 at 10:11 pm

    We just deleted the file and created it again and it seemed to work. I din’t have much time to dig into the details since we were on a deadline, but that wierd issue has not happened again!

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

Sidebar

Related Questions

How does one go about attaching a bunch of code to an onkeydown event,
Consider the console application below, featuring a method with a generic catch handler that
I have a problem with this very simple block of code. please give me
I have a problem attaching an image to a blackberry email. In my code
I have the SQL proc below that I am trying to add a SRS
I'm attaching a PNG image to an e-mail with the following code: ContentValues values
Is it possible that attaching a profiler to a JVM (let's say VisualVM) could
Is there an advantage to dynamically attaching/detaching event handlers? Would manually detaching handlers help
I'm trying to upload documents to SharePoint using web services attaching custom metadata to
I've been using the macro from this blog entry for attaching the Visual Studio

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.