无法在Gridview中查找控件编辑项模板

时间:2017-10-23 14:53:27

标签: c# asp.net

我有以下代码,我试图在dropDownList更新命令中找到SupplierSelectDropDown ID sqldatasource,但我没有尝试过工作

我尝试使用ctl00$Content$DetailsPageControl$PurchaseTabGridView$DXEFL$edit0_4$SupplierSelectDropDown,但该ID会根据行数而变化。任何帮助将不胜感激。

<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>

1 个答案:

答案 0 :(得分:0)

您可以在下拉列表属性中将 ClientIDMode 设置为 static ,以避免生成ID。 然后执行recursive search to find the control以节省您确定哪个是父容器的任务。