CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    ASP.NET : GridView, SqlDataSource and @*_original parameters

    I've tried everything I can think of to get this to work so I am wondering if someone could help.

    According to the docs the update command statement when called via the 'edit/update' on the GridView is supposed to contain @original_ parameters for the existing values rather than the new ones.

    However this just isn't working. Examining the command in the update event of the data source shows they aren't there.

    Am I missing something ? I've read every piece of documentation I can think of.

    Code:
    <asp:SqlDataSource 
        ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:default %>" 
        SelectCommand="select Name, Version, dbo.GetMoneyAsString(A.PricePerUnit, 2) as [PricePerUnit] from dbo.vw_AllFileInformation as A order by Name, Version"
        UpdateCommand="update dbo.vw_AllFileInformation set Name = @Name, Version = @Version, PricePerUnit = @PricePerUnit where Name=@original_Name and Version=@original_Version"
        DeleteCommand="delete from dbo.vw_AllFileInformation where Name = @original_Name and Version=@original_Version"
        DataSourceMode="DataSet" >               
    </asp:SqlDataSource>
    <asp:GridView 
        ID="AllFilesGridView" runat="server" style="width:100%" 
        CellPadding="4" DataSourceID="SqlDataSource1" Font-Size="Small" 
        ForeColor="Teal" GridLines="None" AutoGenerateDeleteButton="True" 
        AutoGenerateEditButton="True" AutoGenerateColumns="false" DataKeyNames="Name,Version"
        EnableViewState="True">
        <RowStyle BackColor="#009090" ForeColor="White" />
        <FooterStyle BackColor="#008080" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#008080" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#008080" Font-Bold="True" ForeColor="Black" />
        <HeaderStyle BackColor="#006060" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#008080" />
        <AlternatingRowStyle BackColor="#00a0a0" ForeColor="White" />                         
        <Columns>
            <asp:BoundField DataField="Name" HeaderText="Name" />
            <asp:BoundField DataField="Version" HeaderText="Version" />
            <asp:BoundField DataField="PricePerUnit" HeaderText="Price Per Unit" />                
        </Columns>
    </asp:GridView>
    Thanks

    Darwen.
    Last edited by darwen; December 9th, 2008 at 07:51 PM.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: ASP.NET : GridView, SqlDataSource and @*_original parameters

    Oops - sorry, wrong forum. Can an admin move this to the ASP.NET forum please ?

    Thanks,

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured