Help... DetailView won't update...

L

LamSoft

The object of DetailView won't update the new record if the updatecommand has the "Where" Clause, but it will update all the rows in the table with the original old values.
, if there is a where clause, it won't update any rows.

May I know what would it happen....
I am really frustrated and no idea of it.....

The code of ASPX
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="listSeverInformation.aspx.cs" Inherits="listSeverInformation" Title="Server Information" Theme="SkinFile"%>
<asp:Content ID="Content" ContentPlaceHolderID="content" Runat="Server">
<div align="center">
Disk Information
</div>
<div align="center" style="padding-top: 20px; width: 100%">
<asp:GridView ID="gvDiskInformation" runat="server" Width="100%">
</asp:GridView>

</div>
<div align="center" style="padding-top: 10px">
Server Information
</div>
<div align="center" style="padding-top: 10px; width: 100%" id="DIV1">
<asp:DetailsView ID="dvServerInformation" runat="server" BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Height="50px" DataSourceID="sDS_ServerInformation"
Width="100%" AutoGenerateRows="False" AutoGenerateEditButton="True" DataKeyNames="server_id" OnItemUpdating="dvServerInformation_Updating" OnItemUpdated="dvServerInformation_Updated">
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<EditRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
<Fields>
<asp:BoundField DataField="server_id" HeaderText="Server ID" SortExpression="server_id" Visible="true" ReadOnly="true" InsertVisible="False" />
<asp:BoundField DataField="serverip" HeaderText="Server IP" SortExpression="serverip" ReadOnly="true" InsertVisible="false"/>
<asp:BoundField DataField="location" HeaderText="Location" SortExpression="location" />
<asp:BoundField DataField="server_owner" HeaderText="Server Owner" SortExpression="server_owner" />
<asp:BoundField DataField="application" HeaderText="Applicaion on the Server" SortExpression="application" />
<asp:BoundField DataField="backup_type" HeaderText="Type of Backup" SortExpression="backup_type" />
<asp:BoundField DataField="remark" HeaderText="Remark" SortExpression="remark" />
</Fields>
</asp:DetailsView>

</div>
<asp:SqlDataSource ID="sDS_ServerInformation" runat="server" ConnectionString="Data Source=MyServer\Test;Initial Catalog=Test;Persist Security Info=True;User ID=user;Password=password"
ProviderName="System.Data.SqlClient"
SelectCommand="SELECT serverDetail.server_id, serverDetail.location, serverDetail.server_owner, serverDetail.application, serverDetail.backup_type, serverList.id, serverList.serverip, serverDetail.remark FROM serverDetail INNER JOIN serverList ON serverDetail.server_id = serverList.id WHERE (serverList.serverip = @serverip)"
UpdateCommand="UPDATE serverDetail SET location = @location, server_owner = @server_owner, application = @application, backup_type = @backup_type, remark = @remark WHERE server_id = @server_id"
<SelectParameters>
<asp:parameter Name="serverip" />
</SelectParameters>
<UpdateParameters>
<asp:parameter Type="string" Name="server_id"/>
<asp:parameter Type="string" Name="location"/>
<asp:parameter Type="string" Name="server_owner" />
<asp:parameter Type="string" Name="application" />
<asp:parameter Type="string" Name="backup_type" />
<asp:parameter Type="string" Name="remark" />
</UpdateParameters>
</asp:SqlDataSource>
</asp:Content>
 

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,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top