为什么我的ASP.NET应用程序显示额外的表?

时间:2013-12-22 12:15:01

标签: c# asp.net gridview repository

这是一个混合(MVC和Web表单)Web应用程序来评价医生。这是我的评级Web表单的代码。为什么在GridView下有第一条记录的额外表?它发生在我按下第一行中的“选择”之后,但是为什么它在我停止并再次运行后停留在那里?这不是缓存问题,因为它显示在不同的浏览器中。提前谢谢!

enter image description here

<%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="Rating.aspx.cs" Inherits="MidtermApplication.Rating" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ObjectDataSource ID="ObjectDataSourceDoctor" runat="server" DeleteMethod="Remove" InsertMethod="Add" SelectMethod="GetDoctor" TypeName="MidtermApplication.Models.TestApplicationDoctorRepo" UpdateMethod="Update" DataObjectTypeName="MidtermApplication.Models.Doctor">
    </asp:ObjectDataSource>
    <asp:GridView ID="GridViewDoctor" runat="server" DataSourceID="ObjectDataSourceDoctor" AutoGenerateColumns="False" OnSelectedIndexChanged="GridViewDoctor_SelectedIndexChanged">
        <Columns>
            <asp:ImageField DataImageUrlField="DoctorPicture" HeaderText="DoctorPicture">
            </asp:ImageField>            
            <asp:BoundField DataField="DoctorName" HeaderText="DoctorName" SortExpression="DoctorName" />
            <asp:BoundField DataField="DoctorSpecialty" HeaderText="DoctorSpecialty" SortExpression="DoctorSpecialty" />
            <asp:TemplateField HeaderText="Rate Now">
                <ItemTemplate>
                <asp:RadioButton ID="RadioButton1" runat="server" GroupName="RateNow" Text="1"></asp:RadioButton>
                <asp:RadioButton ID="RadioButton2" runat="server" GroupName="RateNow" Text="2"></asp:RadioButton>
                <asp:RadioButton ID="RadioButton3" runat="server" GroupName="RateNow" Text="3"></asp:RadioButton>
                <asp:RadioButton ID="RadioButton4" runat="server" GroupName="RateNow" Text="4"></asp:RadioButton>
                <asp:RadioButton ID="RadioButton5" runat="server" GroupName="RateNow" Text="5"></asp:RadioButton>

            </ItemTemplate>
            </asp:TemplateField>
            <asp:ButtonField AccessibleHeaderText="Save Rating" HeaderText="Save Rating" Text="Save" />
            <asp:CheckBoxField DataField="fave" HeaderText="Favorite" SortExpression="fave" InsertVisible="False" Visible="True" />
        </Columns>
    </asp:GridView>

</asp:Content>

代码背后:

namespace MidtermApplication
{
    public partial class Rating : System.Web.UI.Page
    {
        TestApplicationDoctorRepo repo;

        protected void Page_Load(object sender, EventArgs e)
        {
            TestApplicationDoctorRepo.InitApp(this);

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void GridViewDoctor_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}

enter image description here

1 个答案:

答案 0 :(得分:1)

  

为什么在GridView下有第一条记录的额外表?

详细信息视图,您可以在visual studio中以设计模式将其删除。

<强>更新

enter image description here

解决方案:

您必须创建一个新页面,然后重新设计此页面。