views:

175

answers:

1

I'm messing around with a Formview in asp.net. I know that the UpdateCommand needs to be specified so that the Formview knows what SQL query to run.

Do I need to write an event in addition to the code the Formview sets up in order to properly fire off the SQL query?

In addition, I don't get a SQL error or anything, it just does not bind back to the database.

<EditItemTemplate>
        ProductID:
        <asp:Label ID="ProductIDLabel1" runat="server" 
            Text='<%# Eval("ProductID") %>' />
        <br />
        ProductName:
        <asp:TextBox ID="ProductNameTextBox" runat="server" 
            Text='<%# Bind("ProductName") %>' />
        <br />
        UnitPrice:
        <asp:TextBox ID="UnitPriceTextBox" runat="server" 
            Text='<%# Bind("UnitPrice") %>' />
        <br />
        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
            CommandName="Update" Text="Update" />
        &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
            CausesValidation="False" CommandName="Cancel" Text="Cancel" />
    </EditItemTemplate>
A: 

Make sure you set the DataKeys property (usually to the column(s) that are your primary key). If you want more help, you'll need to post your code.

Dan Diplo
The DataKeyName is set to ProductID, the user selects a choice from a DDL which loads the formview with details of the selected product. ASP.net newb here, so any help is appreciated.
patricksweeney
What you've posted looks fine, but we can't see how you are binding to the datasource. Have a look at this reference MSDN example and see if you can spot any differences: http://msdn.microsoft.com/en-us/library/ms227970.aspx Good luck.
Dan Diplo