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
etailsView 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
etailsView>
</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"
<asp
arameter Name="serverip" />
</SelectParameters>
<UpdateParameters>
<asp
arameter Type="string" Name="server_id"/>
<asp
arameter Type="string" Name="location"/>
<asp
arameter Type="string" Name="server_owner" />
<asp
arameter Type="string" Name="application" />
<asp
arameter Type="string" Name="backup_type" />
<asp
arameter Type="string" Name="remark" />
</UpdateParameters>
</asp:SqlDataSource>
</asp:Content>
, 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
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
</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
</SelectParameters>
<UpdateParameters>
<asp
<asp
<asp
<asp
<asp
<asp
</UpdateParameters>
</asp:SqlDataSource>
</asp:Content>