简体   繁体   中英

Can't Find Control Within Gridview Edit Item Template

I have the below code with which I'm trying to find the dropDownList ID of SupplierSelectDropDown in the sqldatasource update command, but nothing I'm trying is working.

I have tried to use ctl00$Content$DetailsPageControl$PurchaseTabGridView$DXEFL$edit0_4$SupplierSelectDropDown but that id changes depending on the number of rows. Any help would be appreciated.

<dx:TabPage Name="Purchase" Text="Purchase">
  <ContentCollection>
    <dx:ContentControl runat="server">
      <dx:ASPxGridView ID="PurchaseTabGridView" runat="server" Theme="Youthful" KeyFieldName="detail_id" Width="100%" AutoGenerateColumns="False" DataSourceID="PurchaseTabDetail">
        <SettingsPager Visible="False"></SettingsPager>
        <SettingsDataSecurity AllowDelete="False" AllowInsert="False" />
        <Columns>
          <dx:GridViewCommandColumn ShowEditButton="True" ShowInCustomizationForm="True" VisibleIndex="0" Caption=" ">
          </dx:GridViewCommandColumn>
          <dx:GridViewDataTextColumn Caption="Code" FieldName="code" ShowInCustomizationForm="True" VisibleIndex="6">
            <EditFormSettings Visible="False" />
          </dx:GridViewDataTextColumn>
          <dx:GridViewDataTextColumn Caption="Description" FieldName="description" ShowInCustomizationForm="True" VisibleIndex="7">
            <EditFormSettings Visible="False" />
          </dx:GridViewDataTextColumn>
          <dx:GridViewDataTextColumn FieldName="supply_trader_id" ShowInCustomizationForm="True" Visible="False" VisibleIndex="10">
          </dx:GridViewDataTextColumn>
          <dx:GridViewDataTextColumn FieldName="supplyname" Caption="Supplier" ShowInCustomizationForm="True" Visible="true" VisibleIndex="8">
            <EditItemTemplate>
              <asp:DropDownList ID="SupplierSelectDropDown" DataSourceID="SupplierSelect" SelectedValue='<%# Eval("supply_trader_id") %>' DataValueField="trader_id" DataTextField="combined" runat="server"></asp:DropDownList>
            </EditItemTemplate>
          </dx:GridViewDataTextColumn>
        </Columns>
      </dx:ASPxGridView>

You can set ClientIDMode to static in your dropdown properties to avoid generated id's. Then perform a recursive search to find the control in order to save you the task of figuring out which is the parent container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM