Gridview编辑按钮不起作用?

时间:2014-07-17 15:33:36

标签: c# asp.net gridview

我有一个从SQL数据库导入数据的gridview。它完全正常,但现在编辑按钮不起作用。我将点击它,进行更改,点击更新,没有任何反应。

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" HeaderStyle-CssClass="FixedHeader"
                CellPadding="4" DataKeyNames="VideoID" DataSourceID="GetKissVideo2013"  OnRowDataBound="GridView1_RowDataBound"
                EmptyDataText="There are no data records to display." AutoPostBack="True" ForeColor="Black" 
                style="margin-left: 0px; margin-top: 0px" Height="302px" Width="722px" 
                BorderStyle="None" BackColor="White" BorderColor="#DEDFDE" BorderWidth="1px" 
                GridLines="Vertical" >
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="Hide" ForeColor="Black" runat="server" CommandName='<%#Bind("VideoID")%>' OnCommand="Remove_Click" OnClientClick="return confirm('Are you sure?')">Hide</asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Event" SortExpression="Event">
                    <ItemTemplate>
                        <asp:Label ID="Event" runat="server" Text='<%#Bind("City") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownList1" runat="server" 
                            DataSourceID="GetKissLocations2013" DataTextField="City" DataValueField="Event"
                            SelectedValue='<%# Bind("Event") %>' />
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="SongTitle" SortExpression="SongTItleID">
                    <ItemTemplate>
                        <asp:Label ID="SongTItleID" runat="server" Text='<%#Bind("SongTitle") %>'></asp:Label>
                    </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="DropDownList2" runat="server" 
                                DataSourceID="GetKissSongs" DataTextField="SongTitle" DataValueField="SongTItleID"
                                SelectedValue='<%# Bind("SongTItleID") %>' />
                        </EditItemTemplate>
                </asp:TemplateField>             
                <asp:BoundField DataField="VideoID" HeaderText="VideoID" SortExpression="VideoID" />
                <asp:BoundField DataField="NumVotes" HeaderText="NumVotes" SortExpression="NumVotes" ReadOnly="True" />           
                <asp:BoundField DataField="StartDate" HeaderText="Start Date" SortExpression="StartDate" />
            </Columns>
            <FooterStyle BackColor="#CCCC99" />
            <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
            <RowStyle BackColor="#F7F7DE" />
            <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#FBFBF2" />
            <SortedAscendingHeaderStyle BackColor="#848384" />
            <SortedDescendingCellStyle BackColor="#EAEAD3" />
            <SortedDescendingHeaderStyle BackColor="#575357" />
        </asp:GridView>

<asp:SqlDataSource ID="GetKissVideo2013" runat="server" 
        ConnectionString=(Stuff) 
        DeleteCommand="DELETE FROM [KissVideo2013] WHERE [ID] = @ID"  
        UpdateCommand="UPDATE [KissVideo2013] SET [Event] = @Event, [SongTItleID] = @SongTItleID, [VideoID] = @VideoID WHERE [ID] = @ID"                                     
        InsertCommand="INSERT INTO [KissVideo2013] ( [Event], [VideoID], [SongTItleID]) VALUES (@Event, @VideoID, @SongTitle)"  >
        <DeleteParameters>
            <asp:Parameter Name="ID" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Event" Type="Int32"/>
            <asp:Parameter Name="SongTItleID" Type="Int32"/>
            <asp:Parameter Name="VideoID" Type="String" />
            <asp:Parameter Name="ID" Type="Int32"/>
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Event" Type="Int32" />
            <asp:Parameter Name="VideoID" Type="String" />
            <asp:Parameter Name="SongTitle" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>

我的选择命令正在后面的代码中执行(但它有效)

看到任何明显我可能已经破产的东西?谢谢 -

0 个答案:

没有答案