Hi
I'm having a problem in an ASP .NET 2.0 Application.
I have a GridView displaying data from an ObjectDataSource (connected to a BLL class which connects to a TabledAdapter (Typed Dataset using optimistic concurrency).
The select (displaying the data) works just fine, however, when I update a row the GridView does pass the old values to the ObjectDataSource.
<DataObjectMethod(DataObjectMethodType.Update, True)> _
Public Function UpdateOC(ByVal original_id As Integer, ByVal original_fotonummer As Integer, ByVal original_inhoud As String, ByVal original_postdatum As Date?, ByVal fotonummer As Integer, ByVal inhoud As String, ByVal postdatum As Date?) As Boolean
Dim tweets As TwitpicOC.TweetsDataTable = adapterOC.GetTweetById(original_id)
If tweets.Rows.Count = 0 Then Return False
Dim row As TwitpicOC.TweetsRow = tweets(0)
SmijtHetErIn(row, original_fotonummer, original_inhoud, original_postdatum)
row.AcceptChanges()
SmijtHetErIn(row, fotonummer, inhoud, postdatum)
Return adapterOC.Update(row) = 1
End Function
Public Sub SmijtHetErIn(ByVal row As TwitpicOC.TweetsRow, ByVal original_fotonummer As Integer, ByVal original_inhoud As String, ByVal original_postdatum As Date?)
With row
.fotonummer = original_fotonummer
If String.IsNullOrEmpty(original_inhoud) Then .SetinhoudNull() Else .inhoud = original_inhoud
If Not original_postdatum.HasValue Then .SetpostdatumNull() Else .postdatum = original_postdatum.Value
End With
End Sub
And this is the part of the page:
<div id='Overzicht' class='post'>
<div class='title'>
<h2>
<a href='javascript:;'>Tweetsoverzicht</a></h2>
<p>
Overzicht</p>
</div>
<div class='entry'>
<p>
<asp:ObjectDataSource ID="odsGebruiker" runat="server" OldValuesParameterFormatString=""
SelectMethod="GetAll" TypeName="TakeHomeWeb.BLL.GebruikersBLL"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsFoto" runat="server" SelectMethod="GetFotosByGebruiker"
TypeName="TakeHomeWeb.BLL.FotosBLL">
<SelectParameters>
<asp:ControlParameter ControlID="ddlGebruiker" DefaultValue="0" Name="userid" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<form id="form1" runat="server">
<asp:Label runat="server" AssociatedControlID="ddlGebruiker">Gebruiker: </asp:Label>
<asp:DropDownList ID="ddlGebruiker" runat="server" AutoPostBack="True" DataSourceID="odsGebruiker"
DataTextField="naam" DataValueField="userid" AppendDataBoundItems="True">
<asp:ListItem Text="Kies een gebruiker" Value="-1" />
</asp:DropDownList>
<br />
<asp:Label runat="server" AssociatedControlID="ddlFoto">Foto: </asp:Label>
<asp:DropDownList ID="ddlFoto" runat="server" AutoPostBack="True" DataSourceID="odsFoto"
DataTextField="url" DataValueField="id" AppendDataBoundItems="True">
<asp:ListItem Value="-1">Kies een foto...</asp:ListItem>
</asp:DropDownList>
<br />
<div style="float: left">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
DataSourceID="odsTweets">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
SortExpression="id" />
<asp:BoundField DataField="fotonummer" HeaderText="fotonummer" SortExpression="fotonummer" />
<asp:BoundField DataField="inhoud" HeaderText="inhoud" SortExpression="inhoud" />
<asp:BoundField DataField="postdatum" HeaderText="postdatum" SortExpression="postdatum" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsTweets" runat="server" ConflictDetection="CompareAllValues"
DeleteMethod="DeleteOC" OldValuesParameterFormatString="original_{0}" SelectMethod="GetTweetsByFotoId"
TypeName="TakeHomeWeb.BLL.TweetsOCBLL" UpdateMethod="UpdateOC">
<DeleteParameters>
<asp:Parameter Name="original_id" Type="Int32" />
<asp:Parameter Name="original_fotonummer" Type="Int32" />
<asp:Parameter Name="original_inhoud" Type="String" />
<asp:Parameter Name="original_postdatum" Type="DateTime" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="original_id" Type="Int32" />
<asp:Parameter Name="original_fotonummer" Type="Int32" />
<asp:Parameter Name="original_inhoud" Type="String" />
<asp:Parameter Name="original_postdatum" Type="DateTime" />
<asp:Parameter Name="fotonummer" Type="Int32" />
<asp:Parameter Name="inhoud" Type="String" />
<asp:Parameter Name="postdatum" Type="DateTime" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="ddlFoto" Name="foto" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</div>
</form>
</p>
</div>
</div>
I've got a feeling there's huge fail involved or something, but I've been staring at it for hours now and I just can't find it.