简体   繁体   中英

Radgrid edit/update not working

I'm having a wired problem with Radgrid.. Im using a Radgrid to display some results where the user can edit/update/delete them. I'm using a single SQL Server 2000 table to fetch the results... Not sure why the events are not firing in radgrid. But I am able to do it successfully using the Gridview control...

Im using .NET framework 4

Radgrid code

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AutoGenerateDeleteColumn="True"
        AutoGenerateEditColumn="True" DataSourceID="SSDS" GridLines="None" Width="844px"
        DataMember="DefaultView">
        <MasterTableView DataSourceID="SSDS" DataKeyNames="id">
            <Columns>
                <telerik:GridBoundColumn DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id"
                    UniqueName="id" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="name" HeaderText="name" SortExpression="name"
                    UniqueName="name">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="address" HeaderText="address" SortExpression="address"
                    UniqueName="address">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <br />
    <br />
    <asp:SqlDataSource ID="SSDS" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringSQL %>"
        ProviderName="<%$ ConnectionStrings:ConnectionStringSQL.ProviderName %>" SelectCommand="SELECT [id], [name], [address] FROM [sitelinks]"
        UpdateCommand="UPDATE [sitelinks] set [name] = ? , [address] = ? where [id] = ?"
        DeleteCommand="delete from sitelinks where id = ?">
        <DeleteParameters>
            <asp:Parameter Name="id" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" />
            <asp:Parameter Name="address" />
            <asp:Parameter Name="id" />
        </UpdateParameters>
    </asp:SqlDataSource>

Gridview control code (the one that works)

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SSDS"
    DataKeyNames="id">
    <Columns>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
            SortExpression="id" Visible="false" />
        <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
        <asp:BoundField DataField="address" HeaderText="address" SortExpression="address" />
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SSDS" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringSQL %>"
    DeleteCommand="delete from sitelinks where id = ?" ProviderName="<%$ ConnectionStrings:ConnectionStringSQL.ProviderName %>"
    SelectCommand="select id,name,address from sitelinks" UpdateCommand="update sitelinks set name=?, address=? where id = ? ">
    <UpdateParameters>
        <asp:ControlParameter ControlID="GridView1" Name="name" />
        <asp:ControlParameter ControlID="GridView1" Name="address" />
        <asp:ControlParameter ControlID="GridView1" Name="id" />
    </UpdateParameters>
    <DeleteParameters>
        <asp:ControlParameter ControlID="GridView1" Name="id" />
    </DeleteParameters>
</asp:SqlDataSource>

Thanks

将telerik网格的AllowAutomaticUpdates / AllowAutomaticDeletes属性设置为true并查看此示例

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM