0

グリッドビューを作成して編集モードを有効にしましたが、各行の「編集」リンクをクリックしても何も起こらず、現在の状態のままです。コードは次のとおりです

<form id="form1" runat="server">
<div>

    <asp:GridView 
        ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="id" 
        DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" 
        AllowSorting="True" PageSize="50" style="text-align: center" Width="100%" OnRowDataBound="GridView1_RowDataBound">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
            <asp:TemplateField HeaderText="full_content" SortExpression="full_content">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" 
                        Text='<%# Bind("full_content", "{0}") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("full_content") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="filename" HeaderText="filename" 
                SortExpression="filename" />
            <asp:BoundField DataField="confidential" HeaderText="confidential" 
                SortExpression="confidential" />
            <asp:BoundField DataField="nid" HeaderText="nid" SortExpression="nid" />
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" 
            HorizontalAlign="Left" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:earchConnectionString %>" 
        SelectCommand="SELECT * FROM [full_content] WHERE ([nid] = @nid)" 
        DeleteCommand="DELETE FROM [full_content] WHERE [id] = @original_id" 
        InsertCommand="INSERT INTO [full_content] ([title], [full_content], [filename], [confidential], [nid]) VALUES (@title, @full_content, @filename, @confidential, @nid)" 
        OldValuesParameterFormatString="original_{0}" 
        UpdateCommand="UPDATE [full_content] SET [title] = @title, [full_content] = @full_content, [filename] = @filename, [confidential] = @confidential, [nid] = @nid WHERE [id] = @original_id">
        <DeleteParameters>
            <asp:Parameter Name="original_id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="title" Type="String" />
            <asp:Parameter Name="full_content" Type="String" />
            <asp:Parameter Name="filename" Type="String" />
            <asp:Parameter Name="confidential" Type="Byte" />
            <asp:Parameter Name="nid" Type="Int32" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="1" Name="nid" QueryStringField="id" 
                Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="title" Type="String" />
            <asp:Parameter Name="full_content" Type="String" />
            <asp:Parameter Name="filename" Type="String" />
            <asp:Parameter Name="confidential" Type="Byte" />
            <asp:Parameter Name="nid" Type="Int32" />
            <asp:Parameter Name="original_id" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

</div>
</form>

誰が問題がどこにあるか知っていますか? ありがとう

4

1 に答える 1

0

次のように追加row editting eventします。

<asp:GridView 
        ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="id" 
        DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" 
        AllowSorting="True" PageSize="50" style="text-align: center" Width="100%" OnRowDataBound="GridView1_RowDataBound"
        OnRowEditing="GridView1_RowEditing">

RowEditingイベントに次のコードを書き留めます。

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
  {
    //Set the edit index.
    GridView1.EditIndex = e.NewEditIndex;
    //Bind data to the GridView control.
    BindData();
  }

行編集に関する詳細データは、ここで取得できます。行編集

于 2012-10-30T06:15:49.263 に答える