views:

1241

answers:

3

I've got the setup below. When I click the 'Edit' link on the CommandField, a RowEditing event gets fired, but the row does not allow me to edit; specifically, the DropDownList does not appear.

My code seems to conform to all the examples I can find.

I'm probably missing something very basic, as I seem to be the only person on the internet having this problem. I'm desperate for another pair of eyes.

Thanks.

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

Hi Dave--

Your code looks OK to me, too. Here are a couple of things that might help your troubleshooting:

  1. Try replacing the EditItemTemplate's DropDownList and ObjectDataSource with some simple text, then see if the text shows up when you click Edit.
  2. Try hooking the GridView up to a DataSource object, and remove the OnRowEditing event from the GridView tag. Then see if the GridView switches to Edit mode OK.
  3. Try moving the ObjectDataSource outside of the GridView. I don't know if it makes any difference, but I usually have mine located outside.

Let us know if this changes anything for you.

Jeremy Kratz
A: 

Try removing your PackageNames ODS from within your GridView. I don't know for sure, but it is a little odd to have it nested within the GridView.

Andrew Robinson
On second thought, it might have nothing to do with your issue....
Andrew Robinson
A: 

I didn't have an ObjectDataSource for the GridView. I was populating it in the code-behind, but apparently you can't do that and use a CommandField.

Dave
It's nice to have the reminder to select an answer or post a bounty. I'd forgotten about this problem.
Dave