一个解决方法是,根据check的情况,将对应编辑栏设置为只读,这样在执行编辑的时候就只有可编辑栏有录入框了

解决方案 »

  1.   

    在Update_click()事件中
    如果Edit by QTY = checked则设置价格Price列的ReadOnly="True"
    反之亦然
      

  2.   

    you probably meant to do it in EditCommand, how does your template look like?if you are using BoundColumn, you can do something like((BoundColumn)YourDataGrid.Items[n]).ReadOnly = true;or consider to do it inside EditItemTemplate
               <asp:TemplateColumn>
                   <HeaderTemplate>
                      <b> Price </b>
                   </HeaderTemplate>               <ItemTemplate>
                      <asp:Label
                           Text='<%# DataBinder.Eval(Container.DataItem, "Price") %>'
                           runat="server"/>
                   </ItemTemplate>               <EditItemTemplate>                  <asp:TextBox id="txt1" 
                          Text='<%# DataBinder.Eval(Container.DataItem, "Price") %>'
          Visible='<%# PriceRadio.Checked %>'
                           runat="server"/>                  <asp:Label
                           Text='<%# DataBinder.Eval(Container.DataItem, "Price") %>'
                     Visible='<%# ! PriceRadio.Checked %>'
                         runat="server"/>               </EditItemTemplate>            </asp:TemplateColumn>
    if you are using AutoGenerateColumns=true, then, after you bind the DataGrid, you need either to replace the TextBox control or try something likeTextBox t =  (TextBox)YourDataGrid.Items[n].FindControl("txt1");
    t.ReadOnly = true;