views:

115

answers:

1

i have the following gridview

            <asp:GridView ID="GridView3" runat="server" AllowPaging="True" AllowSorting="True"
                AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="CommentsDataSource">
                <Columns>
                    <asp:BoundField DataField="Firstname" HeaderText="Firstname" SortExpression="Firstname" />
                    <asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
                    <asp:BoundField DataField="Comment" HeaderText="Comment" />
                    <asp:BoundField DataField="DateAdded" HeaderText="DateAdded" SortExpression="DateAdded" />
                    <asp:TemplateField HeaderText="Approval">
                        <ItemTemplate>
                            <%#Eval("NewsCommentStatus.Name") %>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="DropDownList2" runat="server" SelectedValue='<%# Eval("ApprovalStatusID") %>'
                                DataSourceID="CommentStatusDataSource" DataTextField="Name" DataValueField="ID">
                            </asp:DropDownList>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField ShowEditButton="true" EditImageUrl="~/Admin/Theme/images/Icons/pencil.png"
                        EditText="Edit" />
                </Columns>
            </asp:GridView>
        </ContentTemplate>

and the datasources are:

<asp:LinqDataSource ID="CommentsDataSource" runat="server" ContextTypeName="CMSSystem.Models.CMSDatabaseDataContext"
    TableName="NewsComments" Where="NewsID == @NewsID" EnableUpdate="True">
    <WhereParameters>
        <asp:SessionParameter Name="NewsID" SessionField="NewsItemID" Type="Int32" />
    </WhereParameters>
</asp:LinqDataSource>
<asp:LinqDataSource ID="CommentStatusDataSource" runat="server" ContextTypeName="CMSSystem.Models.CMSDatabaseDataContext"
    TableName="NewsCommentStatus">
</asp:LinqDataSource>

the problem im having is when the combobox is changed the value is not being updated is there something obvious i've missed?

+1  A: 

Use Bind instead of Eval. Bind is used for two way databinding :

<asp:DropDownList ID="DropDownList2" runat="server" SelectedValue='<%# Bind("ApprovalStatusID") %>'
    DataSourceID="CommentStatusDataSource" DataTextField="Name" DataValueField="ID">
</asp:DropDownList>
Canavar
yep thats the problem thanks a lot!
Stephen Binns