在Update_click()事件中 如果Edit by QTY = checked则设置价格Price列的ReadOnly="True" 反之亦然
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;
如果Edit by QTY = checked则设置价格Price列的ReadOnly="True"
反之亦然
<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;