What happen to the DetailView, oldValues and newValues are the same....

L

LamSoft

In the object of detailView, i added a function to check the values during itemUpdating, the source is:

protected void test2(object sender, DetailsViewUpdateEventArgs e)
{
foreach (System.Collections.DictionaryEntry o in e.OldValues)
{
Response.Write("Old Values:" + o.Key.ToString() + "==>" + o.Value + "<br/>");
}
foreach (System.Collections.DictionaryEntry o in e.NewValues)
{
Response.Write("New Values:" + o.Key.ToString() + "==>" + o.Value + "<br/>");
}
Response.End();
}

<asp:DetailsView ID="dv_ServerInformation" runat="server" AutoGenerateEditButton="True" AutoGenerateRows="False" DataSourceID="sDS_ServerInformation" Height="50px" Width="80%" OnItemUpdated="test" DataKeyNames="server_id" OnItemUpdating="test2">
<Fields>
<asp:BoundField DataField="serverip" HeaderText="Server IP" ReadOnly="True" SortExpression="serverip" />
<asp:BoundField DataField="location" HeaderText="Location" SortExpression="location" />
<asp:BoundField DataField="server_owner" HeaderText="Server Owner" SortExpression="server_owner" />
<asp:BoundField DataField="application" HeaderText="Server Application" SortExpression="application" />
<asp:BoundField DataField="backup_type" HeaderText="Backup Type" SortExpression="backup_type" />
<asp:BoundField DataField="remark" HeaderText="Remark" SortExpression="remark" />
<asp:BoundField DataField="server_id" HeaderText="server_id" SortExpression="server_id"
Visible="False" />
</Fields>
</asp:DetailsView>

While a user modify some values in the detailview and click update, the new values in the object "e" should be different from the old values, however the result is same.... which made me fail to update database (because old values and new values are the same, nothing updated...), is it a bug or anything i made wrong? Thanks

Old Values:serverip==>10.10.10.193
Old Values:location==>5555
Old Values:server_owner==>55555
Old Values:application==>55
Old Values:backup_type==>55555555
Old Values:remark==>555555
New Values:location==>5555
New Values:server_owner==>55555
New Values:application==>55
New Values:backup_type==>55555555
New Values:remark==>555555
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top