form view not updating!

Last post 06-19-2007 5:26 PM by LockH. 2 replies.

Sort Posts:

  • form view not updating!

    06-18-2007, 7:35 PM
    • Loading...
    • smartsl
    • Joined on 12-15-2006, 4:21 PM
    • Posts 41

     I have a page that has multiple formview's and multiple SQL sources on it...

     I have selected data from my database that needs to be edited based on a sessin variabe. When i edit one of the formview's, it works just fine, but when I edit another...it wont update. The formviews that wont update have default values in them and when it doesn't update, the default value is inserted into the database...so I know the connection is working.

    The "Edit" mode of the webform just isnt posting the text to the database. What is going on?

    This is driving me nuts as it is a very important page! 

  • Re: form view not updating!

    06-19-2007, 3:33 PM
    • Loading...
    • smartsl
    • Joined on 12-15-2006, 4:21 PM
    • Posts 41

     Can someone please help me with this? I've looked at other solutions for this problem and THINK I've solved them all but my formview(s) wont update. Here is my forview and SQLdatasource code:

    FORM VIEW:

     <asp:FormView ID="FormView_Personal" runat="server" DataSourceID="SqlDataSource_MyProfilePersonal"
            Width="100%" DefaultMode="Edit">
            <EditItemTemplate>
                <table style="width: 100%" cellspacing="0" cellpadding="0" border="0">
                    <tbody>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblActivitiestxt" runat="server" Text="Activities:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:TextBox ID="txtAct" runat="server" Width="400px" Text='<%# Bind("Activities") %>'
                                    Rows="4" MaxLength="1000" TextMode="MultiLine" Height="100px"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblInterests" runat="server" Text="Interests:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:TextBox ID="txtInt" runat="server" Width="400px" Text='<%# Bind("Interests") %>'
                                    Rows="4" MaxLength="1000" TextMode="MultiLine" Height="100px"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteMusic" runat="server" Text="Favorite Music:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:TextBox ID="txtFavMusic" runat="server" Width="400px" Text='<%# Bind("FavoriteMusic") %>'
                                    Rows="4" MaxLength="1000" TextMode="MultiLine" Height="100px"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteTVShowstext" runat="server" Text="Favorite TV Shows:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:TextBox ID="txtFavTV" runat="server" Width="400px" Text='<%# Bind("FavoriteTVShows") %>'
                                    Rows="4" MaxLength="1000" TextMode="MultiLine" Height="100px"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteMovies" runat="server" Text="Favorite Movies:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:TextBox ID="txtFavMovies" runat="server" Width="400px" Text='<%# Bind("FavoriteMovies") %>'
                                    Rows="4" MaxLength="1000" TextMode="MultiLine" Height="100px"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteBooks" runat="server" Text="Favorite Books:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:TextBox ID="txtFavBooks" runat="server" Width="400px" Text='<%# Bind("FavoriteBooks") %>'
                                    MaxLength="1000" TextMode="MultiLine" Height="100px"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteQuotes" runat="server" Text="Favorite Quotes:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:TextBox ID="txtFavQuotes" runat="server" Width="400px" Text='<%# Bind("FavoriteQuotes") %>'
                                    MaxLength="1000" TextMode="MultiLine" Height="100px"></asp:TextBox></td>
                        </tr>
                    </tbody>
                </table>
                <asp:LinkButton ID="lnkEditPersoanl" runat="server" Text="Update" CommandName="Update"
                    CssClass="FormViewButton"></asp:LinkButton>
                <asp:LinkButton ID="UpdateCancelButtontext" runat="server" Text="Cancel" CommandName="Cancel"
                    CssClass="FormViewButton" CausesValidation="False"></asp:LinkButton>
            </EditItemTemplate>
            <ItemTemplate>
                <table style="width: 100%" cellspacing="0" cellpadding="0" border="0">
                    <tbody>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblActivities" runat="server" Text="Activities:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:Label ID="lblActivitiesText" runat="server" Text='<%# Bind("Activities") %>'
                                    CssClass="TabsRightSide"></asp:Label></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblInterestsPersonal" runat="server" Text="Interests:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:Label ID="lblInterestsText" runat="server" Text='<%# Bind("Interests") %>' CssClass="TabsRightSide"></asp:Label></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteMusicPersonal" runat="server" Text="Favorite Music:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:Label ID="lblFavoriteMusicText" runat="server" Text='<%# Eval("FavoriteMusic") %>'
                                    CssClass="TabsRightSide"></asp:Label></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteTVShows" runat="server" Text="Favorite TV Shows:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:Label ID="lblFavoriteTVShowsText" runat="server" Text='<%# Eval("FavoriteTVShows") %>'
                                    CssClass="TabsRightSide"></asp:Label></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteMoviesPersonal" runat="server" Text="Favorite Movies:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:Label ID="lblFavoriteMoviesText" runat="server" Text='<%# Eval("FavoriteMovies") %>'
                                    CssClass="TabsRightSide"></asp:Label></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteBooksPersonal" runat="server" Text="Favorite Books:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:Label ID="lblFavoriteBooksText" runat="server" Text='<%# Eval("FavoriteBooks") %>'
                                    CssClass="TabsRightSide"></asp:Label></td>
                        </tr>
                        <tr>
                            <td style="width: 30%" class="TabsLeftSide" valign="top" align="left">
                                <asp:Label ID="lblFavoriteQuotesPersonal" runat="server" Text="Favorite Quotes:"></asp:Label></td>
                            <td style="width: 70%" valign="top" align="left">
                                <asp:Label ID="lblFavoriteQuotesText" runat="server" Text='<%# Eval("FavoriteQuotes") %>'
                                    CssClass="TabsRightSide"></asp:Label></td>
                        </tr>
                    </tbody>
                </table>
            </ItemTemplate>
        </asp:FormView>

    SQL Datasource:

     <asp:SqlDataSource ID="SqlDataSource_MyProfilePersonal" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString22222 %>"
            SelectCommand="SELECT NationalID, FavoriteQuotes, FavoriteBooks, FavoriteMovies, FavoriteTVShows, FavoriteMusic, Interests, Activities, UserID FROM tblMembers WHERE (UserID = @UserID)"
            UpdateCommand="UPDATE tblMembers SET Activities = @Act, Interests = @Int, FavoriteMusic = @FavMusic, FavoriteTVShows = @FavTV, FavoriteMovies = @FavMovies, FavoriteBooks = @FavBooks, FavoriteQuotes = @FavQuotes WHERE (UserID = @UserID)">
            <UpdateParameters>
                <asp:SessionParameter Name="UserID" SessionField="UserID" />
                <asp:FormParameter FormField="txtAct" Name="Act" />
                <asp:Parameter Name="Int" />
                <asp:Parameter Name="FavMusic" />
                <asp:Parameter Name="FavTV" />
                <asp:Parameter Name="FavMovies" />
                <asp:Parameter Name="FavBooks" />
                <asp:Parameter Name="FavQuotes" />
            </UpdateParameters>
            <SelectParameters>
                <asp:SessionParameter SessionField="UserID" Name="UserID"></asp:SessionParameter>
            </SelectParameters>
        </asp:SqlDataSource>

     

    Filed under: , , ,
  • Re: form view not updating!

    06-19-2007, 5:26 PM
    Answer
    • Loading...
    • LockH
    • Joined on 03-25-2007, 10:58 AM
    • Scotland, where whisky has no e.
    • Posts 570

    I would suggest changing your UpdateParameters.

    The first one is a SessionParameter, we assume it does point at a session item.

    The next one is a FormParameter, the rest are plain Parameter.

    Why the difference?

    I'd make them all like <asp:Parameter Name="Activities" /> using the name of the data item you bound your text boxes to.

    If you look at your third parameter it has Name="Int".  There is nothing at all to connect that to your text box "txtInt" which is bound to "Interests", and no hint at all  that whatever the user types in the txtInt should be copied into this parameter.

    So call it "Interests"; and so on for the rest of them.

    If a post helps to solve your problem, please click the Answer button on that post.

    I'm still confused, but now I'm confused on a higher plane.
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter