Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Duplicate ID on Template
posted

I built a webgrid which has a value change according on the the base column.  My question is there another way to do the refresh then an autopostback, and if not, how do I perform the auto post back without this error:

Multiple controls with the same ID '0_0' were found. FindControl requires that controls have unique IDs.
[HttpException (0x80004005): Multiple controls with the same ID '0_0' were found. FindControl requires that controls have unique IDs.]
   System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +273
   System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +320
   System.Web.UI.Control.EnsureNamedControlsTable() +61
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +222
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +327
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +327
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +327
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +327
   System.Web.UI.Page.FindControl(String id) +38
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +113
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Here is my code:
<ig:WebDataGrid ID="myWebGrid" runat="server" Width="100%" AutoGenerateColumns="False" DataSourceID="values">
<Behaviors>
<ig:ColumnResizing />
<ig:Selection CellClickAction="Row" RowSelectType="Multiple"/>
</Behaviors>
<Columns>
<ig:TemplateDataField Key="NameTemplate">
<Header Text="Name" />
<ItemTemplate><%# Eval("Value.Name")%></ItemTemplate>
</ig:TemplateDataField>
<ig:TemplateDataField Key="TypeTemplate">
<Header Text="Value Type" />
<ItemTemplate>
<asp:DropDownList runat="server" ID="_valueTypeDropDown" SelectedIndex='<%# Bind("ValueType.ValueType")%>' AutoPostBack=true>
<asp:ListItem> Frequency </asp:ListItem>
<asp:ListItem> On Change </asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</ig:TemplateDataField>
<ig:TemplateDataField Key="HertzTemplate">
<Header Text="Hertz" />
<ItemTemplate><asp:TextBox ID="_hertzTextBox" runat="server" Text='<%# Bind("ValueType.Value")%>' Enabled='<%# (Elums.Enterprise.Core.ValueTypeValue.Frequency.Equals(Eval("ValueType.ValueType"))) %>' /></ItemTemplate>
</ig:TemplateDataField>
</Columns>
</ig:WebDataGrid>

Parents
No Data
Reply
  • 175
    posted

     

    We've been running into the same problem using v10.3 SR 2134.

    To workaround the issue we've added the following extra WebDataGrid clearing logic (inside the 'doExtraClearingLogic' if block) to be executed only during the re-binds that were causing us to receive the multiple controls with the same ID errors.

    grdSelectedHorse.Rows.Clear()
    grdSelectedHorse.ClearDataSource()
    If doExtraClearingLogic Then
         Dim templateControlContainer As PropertyInfo = grdSelectedHorse.GetType.GetProperty("TemplateContainerControl", Reflection.BindingFlags.GetProperty Or Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic)
         DirectCast(templateControlContainer.GetValue(grdSelectedHorse, Nothing), Control).Controls.Clear()
    End If
    grdSelectedHorse.DataSource = list
    grdSelectedHorse.DataBind()

    Note: 'grdSelectedHorse' is our WebDataGrid & 'list' is a Generic.List of anonymous typed objects in our case

    Hope this helps someone!

Children
No Data