关于DetailsView的新建编辑

来源:百度知道 编辑:UC知道 时间:2024/06/25 05:24:43
我有一个学生信息的detailsView控件需要修改。学生登陆,如果没有该学生信息,detailsview可以新建;如果已经有该学生信息,就在detailsview读出,然后不要新建。

如图所示,下图中的新建按钮应该如何去除。或者这样就是不行的,需要用其它方法。
没有btnCreate这样的按钮,detailsview在后台不知道如何获取控件的ID。
前台代码:
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSourceMajor">
<InsertItemTemplate>
Content:
<asp:TextBox ID="ContentTextBox" runat="server" Text='<%# Bind("Content") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Visible="false"
Text="插入">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="取消">
</asp:LinkButton>
<

您好,您的DetailsView如果类似如下,

<asp:DetailsView ID="dtlView" runat="server" AutoGenerateRows="False"
Height="50px" Width="125px">
<FooterTemplate>
<asp:Button ID="btnEdit" runat="server" Text="编辑" />
<asp:Button ID="btnCreate" runat="server" Text="新建" />
</FooterTemplate>
<Fields>
<asp:BoundField DataField="Name" HeaderText="姓名" SortExpression="Name" />
<asp:BoundField DataField="Gender" HeaderText="性别" SortExpression="Gender" />
</Fields>
</asp:DetailsView>

则你只要去掉<asp:Button ID="btnCreate" runat="server" Text="新建" />即可,如果去掉后出现无法编译,则不要去掉,改成<asp:Button ID="btn