代码如下.
<%@ Page Language="C#" MasterPageFile="~/Admin/admin.master" AutoEventWireup="true" CodeFile="Admin_Info.aspx.cs" Inherits="Admin_Admin_Info" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table style="width: 558px; position: relative">
        <tr>
            <td style="width: 100px; height: 21px">
                <asp:HyperLink ID="HyperLink1" runat="server" Style="position: relative">添加管理员</asp:HyperLink></td>
            <td style="width: 100px; height: 21px">
                <asp:HyperLink ID="HyperLink2" runat="server" Style="position: relative">管理员信息</asp:HyperLink></td>
            <td style="width: 100px; height: 21px">
            </td>
            <td style="width: 100px; height: 21px">
            </td>
        </tr>
    </table>
    <table style="left: 150px; width: 246px; position: relative; top: 2px">
        <tr>
            <td style="width: 100px">
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT * FROM [AdminInfo] WHERE ([Admin_ID]=@Admin_ID)"
                    UpdateCommand="UPDATE AdminInfo SET Admin_name=@Admin_name,Admin_psw=@Admin_psw,Admin_realName=@Admin_realName,Admin_email=@Admin_email,Admin_addDate=@Admin_addDate WHERE (Admin_ID=@Admin_ID)" ConnectionString="<%$ ConnectionStrings:T_eshopConnectionString2 %>">
                    <UpdateParameters>
                        <asp:ControlParameter ControlID="DetailsView1" Name="Admin_name" PropertyName="SelectedValue" />
                        <asp:ControlParameter ControlID="DetailsView1" Name="Admin_psw" PropertyName="SelectedValue" />
                        <asp:ControlParameter ControlID="DetailsView1" Name="Admin_realName" PropertyName="SelectedValue" />
                        <asp:ControlParameter ControlID="DetailsView1" Name="Admin_email" PropertyName="SelectedValue" />
                        <asp:ControlParameter ControlID="DetailsView1" Name="Admin_addDate" PropertyName="SelectedValue" />
                        <asp:QueryStringParameter Name="Admin_ID" QueryStringField="aid" />
                    </UpdateParameters>
                    <SelectParameters>
                        <asp:Parameter Name="Admin_ID" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
    <table style="left: 201px; width: 197px; position: relative; top: 4px">
        <tr>
            <td style="width: 100px; color: #ff33ff; text-decoration: underline; text-align: center; display: block;">
                管理员详细信息</td>
        </tr>
    </table>
    <table style="width: 558px; position: relative">
        <tr>
            <td style="width: 100px; height: 18px;">
                <asp:Label ID="lblMsg" runat="server" Style="position: relative" Text="lblMsg" Width="546px"></asp:Label></td>
        </tr>
    </table>
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
        Height="50px" OnItemUpdating="DetailsView1_ItemUpdating" Style="left: 7px; position: relative;
        top: 4px; text-align: right;" Width="423px" OnItemUpdated="ItemUpdated" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" >
        <Fields>
            <asp:BoundField DataField="Admin_ID" HeaderText="管量员ID" ReadOnly="True" />
            <asp:BoundField DataField="Admin_name" HeaderText="用户名" ReadOnly="True" />
            <asp:BoundField DataField="Admin_psw" HeaderText="密码" />
            <asp:BoundField DataField="Admin_realName" HeaderText="真实姓名" />
            <asp:BoundField DataField="Admin_email" HeaderText="邮件地址" />
            <asp:BoundField DataField="Admin_addDate" HeaderText="添加时间" />
            <asp:CommandField ButtonType="Button" ShowEditButton="True" />
        </Fields>
        <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
        <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
        <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
    </asp:DetailsView>
</asp:Content>

解决方案 »

  1.   

    SELECT * FROM [AdminInfo] WHERE ([Admin_ID]=@Admin_ID)
    这条语句不加后面条件,我在查询分析器里试了,是可以的.
      

  2.   

    看来代码才知道,你是前台绑定数据源的,一般很少那么做private void Page_Load(object sender, System.EventArgs e)
    {
       if(!IsPostback)
       {
           DataSet ds=new DataSet();
           ds=得到的结果集
            this.DataGrid1.DataSource=ds.Table[0];
           this.DataGrid1.DataBind();
       }
    }