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

Discussion in 'ASP .Net' started by LamSoft, Jul 5, 2007.

  1. LamSoft

    LamSoft Guest

    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>
     
    LamSoft, Jul 5, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Henry Lee

    DetailView Data Update Error

    Henry Lee, Mar 2, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    954
    Henry Lee
    Mar 2, 2006
  2. Remy
    Replies:
    0
    Views:
    519
  3. =?Utf-8?B?QmVydA==?=

    detailview update

    =?Utf-8?B?QmVydA==?=, Jan 5, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    318
    =?Utf-8?B?QmVydA==?=
    Jan 5, 2007
  4. Randy

    Update From DropDownList in DetailView

    Randy, May 5, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    142
    Randy
    May 7, 2006
  5. Net

    Need help with Update and Delete in DetailView

    Net, Jun 2, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    137
Loading...

Share This Page