我已經完成了下面的設置。當我點擊CommandField上的「編輯」鏈接時,RowEditing事件被觸發,但該行不允許我編輯;具體而言,DropDownList不會出現。GridView中的DropDownList在編輯時不可用
我的代碼似乎符合我可以找到的所有示例。
我可能錯過了一些非常基本的東西,因爲我似乎是互聯網上唯一有這個問題的人。我迫切需要另一雙眼睛。
謝謝。
<asp:GridView ID="grdvMachine1" runat="server" AutoGenerateColumns="False" CellSpacing="2"
CssClass="GridViewFormat" GridLines="None" Width="500px"
OnRowUpdating="grdvMachine1_RowUpdating" OnRowUpdated="grdvMachine1_RowUpdated"
OnRowEditing="grdvMachine1_RowEditing" OnRowDeleting="grdvMachine1_RowDeleting">
<PagerSettings Position="Top" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<Columns>
<asp:BoundField DataField="Day Of Week" HeaderText="Day Of Week" SortExpression="Day Of Week" />
<asp:TemplateField HeaderText="Package" SortExpression="Package">
<EditItemTemplate>
<asp:DropDownList ID="comboPackageNames"
runat="server"
DataSourceID="PackageNames"
DataTextField="PackageName"
DataValueField="PackageName"
SelectedValue='<%# Bind("Package") %>'>
</asp:DropDownList>
<asp:ObjectDataSource ID="PackageNames" runat="server" SelectMethod="GetSPPList"
TypeName="PCS.WebApp.DefaultSchedules">
</asp:ObjectDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Package") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true"/>
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" HorizontalAlign="Center" VerticalAlign="Middle" />
<EmptyDataTemplate>
There is no schedule for the selected machine
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#008A8C" Font-Bold="False" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" HorizontalAlign="Center"
VerticalAlign="Middle" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
很高興有提醒選擇答案或發佈賞金。我忘記了這個問題。 – Dave 2009-03-17 13:23:23