ASP プロジェクトのデータベースにデータ バインドされたリストビュー コントロールがあり、編集できるように設定しています。リストビューはマルチビュー内にあり、情報を完全にロードしますが、編集ボタンをクリックしても何もしません。リストビューは更新パネルにありますが、その一部である可能性がありますが、リストビューを更新パネルの外に置くだけで、マルチビューがビューをデフォルトのページロードビューに戻します。
ほぼ同じ状況で、以前のプロジェクトで完全に機能する編集可能なリストビューを持っていますが、これが機能しない理由がわかりません。削除して再作成しようとしましたが、この問題はマルチビューで作成したリストビューに影響しているようです。「挿入」機能を実装した他のリストビューでは、挿入ボタンも何もしません。
私のコードは以下の通りです:
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:ListView ID="ListView2" runat="server" DataKeyNames="StudentID"
DataSourceID="SqlDataSource10" GroupItemCount="3">
<AlternatingItemTemplate>
<td runat="server" style="background-color: #FFFFFF;color: #284775;">
StudentID:
<asp:Label ID="StudentIDLabel" runat="server" Text='<%# Eval("StudentID") %>' />
<br />
CurrentSchoolID:
<asp:Label ID="CurrentSchoolIDLabel" runat="server"
Text='<%# Eval("CurrentSchoolID") %>' />
<br />
Gender:
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
<br />
Fname:
<asp:Label ID="FnameLabel" runat="server" Text='<%# Eval("Fname") %>' />
<br />
Lname:
<asp:Label ID="LnameLabel" runat="server" Text='<%# Eval("Lname") %>' />
<br />
ParentCarer:
<asp:Label ID="ParentCarerLabel" runat="server"
Text='<%# Eval("ParentCarer") %>' />
<br />
StAddress:
<asp:Label ID="StAddressLabel" runat="server" Text='<%# Eval("StAddress") %>' />
<br />
suburb:
<asp:Label ID="suburbLabel" runat="server" Text='<%# Eval("suburb") %>' />
<br />
postCode:
<asp:Label ID="postCodeLabel" runat="server" Text='<%# Eval("postCode") %>' />
<br />
DOB:
<asp:Label ID="DOBLabel" runat="server" Text='<%# Eval("DOB") %>' />
<br />
homePhone:
<asp:Label ID="homePhoneLabel" runat="server" Text='<%# Eval("homePhone") %>' />
<br />
MobilePhone:
<asp:Label ID="MobilePhoneLabel" runat="server"
Text='<%# Eval("MobilePhone") %>' />
<br />
WorkPhone:
<asp:Label ID="WorkPhoneLabel" runat="server" Text='<%# Eval("WorkPhone") %>' />
<br />
email:
<asp:Label ID="emailLabel" runat="server" Text='<%# Eval("email") %>' />
<br />
UserID:
<asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />
<br />
Username:
<asp:Label ID="UsernameLabel" runat="server" Text='<%# Eval("Username") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
</td>
</AlternatingItemTemplate>
<EditItemTemplate>
<td runat="server" style="background-color: #999999;">
StudentID:
<asp:Label ID="StudentIDLabel1" runat="server"
Text='<%# Eval("StudentID") %>' />
<br />
CurrentSchoolID:
<asp:TextBox ID="CurrentSchoolIDTextBox" runat="server"
Text='<%# Bind("CurrentSchoolID") %>' />
<br />
Gender:
<asp:TextBox ID="GenderTextBox" runat="server" Text='<%# Bind("Gender") %>' />
<br />
Fname:
<asp:TextBox ID="FnameTextBox" runat="server" Text='<%# Bind("Fname") %>' />
<br />
Lname:
<asp:TextBox ID="LnameTextBox" runat="server" Text='<%# Bind("Lname") %>' />
<br />
ParentCarer:
<asp:TextBox ID="ParentCarerTextBox" runat="server"
Text='<%# Bind("ParentCarer") %>' />
<br />
StAddress:
<asp:TextBox ID="StAddressTextBox" runat="server"
Text='<%# Bind("StAddress") %>' />
<br />
suburb:
<asp:TextBox ID="suburbTextBox" runat="server" Text='<%# Bind("suburb") %>' />
<br />
postCode:
<asp:TextBox ID="postCodeTextBox" runat="server"
Text='<%# Bind("postCode") %>' />
<br />
DOB:
<asp:TextBox ID="DOBTextBox" runat="server" Text='<%# Bind("DOB") %>' />
<br />
homePhone:
<asp:TextBox ID="homePhoneTextBox" runat="server"
Text='<%# Bind("homePhone") %>' />
<br />
MobilePhone:
<asp:TextBox ID="MobilePhoneTextBox" runat="server"
Text='<%# Bind("MobilePhone") %>' />
<br />
WorkPhone:
<asp:TextBox ID="WorkPhoneTextBox" runat="server"
Text='<%# Bind("WorkPhone") %>' />
<br />
email:
<asp:TextBox ID="emailTextBox" runat="server" Text='<%# Bind("email") %>' />
<br />
UserID:
<asp:TextBox ID="UserIDTextBox" runat="server" Text='<%# Bind("UserID") %>' />
<br />
Username:
<asp:TextBox ID="UsernameTextBox" runat="server"
Text='<%# Bind("Username") %>' />
<br />
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<br />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
<br />
</td>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<EmptyItemTemplate>
<td runat="server" />
</EmptyItemTemplate>
<GroupTemplate>
<tr ID="itemPlaceholderContainer" runat="server">
<td ID="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
<InsertItemTemplate>
<td runat="server" style="">
CurrentSchoolID:
<asp:TextBox ID="CurrentSchoolIDTextBox" runat="server"
Text='<%# Bind("CurrentSchoolID") %>' />
<br />
Gender:
<asp:TextBox ID="GenderTextBox" runat="server" Text='<%# Bind("Gender") %>' />
<br />
Fname:
<asp:TextBox ID="FnameTextBox" runat="server" Text='<%# Bind("Fname") %>' />
<br />
Lname:
<asp:TextBox ID="LnameTextBox" runat="server" Text='<%# Bind("Lname") %>' />
<br />
ParentCarer:
<asp:TextBox ID="ParentCarerTextBox" runat="server"
Text='<%# Bind("ParentCarer") %>' />
<br />
StAddress:
<asp:TextBox ID="StAddressTextBox" runat="server"
Text='<%# Bind("StAddress") %>' />
<br />
suburb:
<asp:TextBox ID="suburbTextBox" runat="server" Text='<%# Bind("suburb") %>' />
<br />
postCode:
<asp:TextBox ID="postCodeTextBox" runat="server"
Text='<%# Bind("postCode") %>' />
<br />
DOB:
<asp:TextBox ID="DOBTextBox" runat="server" Text='<%# Bind("DOB") %>' />
<br />
homePhone:
<asp:TextBox ID="homePhoneTextBox" runat="server"
Text='<%# Bind("homePhone") %>' />
<br />
MobilePhone:
<asp:TextBox ID="MobilePhoneTextBox" runat="server"
Text='<%# Bind("MobilePhone") %>' />
<br />
WorkPhone:
<asp:TextBox ID="WorkPhoneTextBox" runat="server"
Text='<%# Bind("WorkPhone") %>' />
<br />
email:
<asp:TextBox ID="emailTextBox" runat="server" Text='<%# Bind("email") %>' />
<br />
UserID:
<asp:TextBox ID="UserIDTextBox" runat="server" Text='<%# Bind("UserID") %>' />
<br />
Username:
<asp:TextBox ID="UsernameTextBox" runat="server"
Text='<%# Bind("Username") %>' />
<br />
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<br />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
<br />
</td>
</InsertItemTemplate>
<ItemTemplate>
<td runat="server" style="background-color: #E0FFFF;color: #333333;">
StudentID:
<asp:Label ID="StudentIDLabel" runat="server" Text='<%# Eval("StudentID") %>' />
<br />
CurrentSchoolID:
<asp:Label ID="CurrentSchoolIDLabel" runat="server"
Text='<%# Eval("CurrentSchoolID") %>' />
<br />
Gender:
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
<br />
Fname:
<asp:Label ID="FnameLabel" runat="server" Text='<%# Eval("Fname") %>' />
<br />
Lname:
<asp:Label ID="LnameLabel" runat="server" Text='<%# Eval("Lname") %>' />
<br />
ParentCarer:
<asp:Label ID="ParentCarerLabel" runat="server"
Text='<%# Eval("ParentCarer") %>' />
<br />
StAddress:
<asp:Label ID="StAddressLabel" runat="server" Text='<%# Eval("StAddress") %>' />
<br />
suburb:
<asp:Label ID="suburbLabel" runat="server" Text='<%# Eval("suburb") %>' />
<br />
postCode:
<asp:Label ID="postCodeLabel" runat="server" Text='<%# Eval("postCode") %>' />
<br />
DOB:
<asp:Label ID="DOBLabel" runat="server" Text='<%# Eval("DOB") %>' />
<br />
homePhone:
<asp:Label ID="homePhoneLabel" runat="server" Text='<%# Eval("homePhone") %>' />
<br />
MobilePhone:
<asp:Label ID="MobilePhoneLabel" runat="server"
Text='<%# Eval("MobilePhone") %>' />
<br />
WorkPhone:
<asp:Label ID="WorkPhoneLabel" runat="server" Text='<%# Eval("WorkPhone") %>' />
<br />
email:
<asp:Label ID="emailLabel" runat="server" Text='<%# Eval("email") %>' />
<br />
UserID:
<asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />
<br />
Username:
<asp:Label ID="UsernameLabel" runat="server" Text='<%# Eval("Username") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
</td>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="groupPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr ID="groupPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF">
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<td runat="server"
style="background-color: #E2DED6;font-weight: bold;color: #333333;">
StudentID:
<asp:Label ID="StudentIDLabel" runat="server" Text='<%# Eval("StudentID") %>' />
<br />
CurrentSchoolID:
<asp:Label ID="CurrentSchoolIDLabel" runat="server"
Text='<%# Eval("CurrentSchoolID") %>' />
<br />
Gender:
<asp:Label ID="GenderLabel" runat="server" Text='<%# Eval("Gender") %>' />
<br />
Fname:
<asp:Label ID="FnameLabel" runat="server" Text='<%# Eval("Fname") %>' />
<br />
Lname:
<asp:Label ID="LnameLabel" runat="server" Text='<%# Eval("Lname") %>' />
<br />
ParentCarer:
<asp:Label ID="ParentCarerLabel" runat="server"
Text='<%# Eval("ParentCarer") %>' />
<br />
StAddress:
<asp:Label ID="StAddressLabel" runat="server" Text='<%# Eval("StAddress") %>' />
<br />
suburb:
<asp:Label ID="suburbLabel" runat="server" Text='<%# Eval("suburb") %>' />
<br />
postCode:
<asp:Label ID="postCodeLabel" runat="server" Text='<%# Eval("postCode") %>' />
<br />
DOB:
<asp:Label ID="DOBLabel" runat="server" Text='<%# Eval("DOB") %>' />
<br />
homePhone:
<asp:Label ID="homePhoneLabel" runat="server" Text='<%# Eval("homePhone") %>' />
<br />
MobilePhone:
<asp:Label ID="MobilePhoneLabel" runat="server"
Text='<%# Eval("MobilePhone") %>' />
<br />
WorkPhone:
<asp:Label ID="WorkPhoneLabel" runat="server" Text='<%# Eval("WorkPhone") %>' />
<br />
email:
<asp:Label ID="emailLabel" runat="server" Text='<%# Eval("email") %>' />
<br />
UserID:
<asp:Label ID="UserIDLabel" runat="server" Text='<%# Eval("UserID") %>' />
<br />
Username:
<asp:Label ID="UsernameLabel" runat="server" Text='<%# Eval("Username") %>' />
<br />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<br />
</td>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource10" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [Student] WHERE [StudentID] = @StudentID"
InsertCommand="INSERT INTO [Student] ([CurrentSchoolID], [Gender], [Fname], [Lname], [ParentCarer], [StAddress], [suburb], [postCode], [DOB], [homePhone], [MobilePhone], [WorkPhone], [email], [UserID], [Username]) VALUES (@CurrentSchoolID, @Gender, @Fname, @Lname, @ParentCarer, @StAddress, @suburb, @postCode, @DOB, @homePhone, @MobilePhone, @WorkPhone, @email, @UserID, @Username)"
SelectCommand="SELECT * FROM [Student] WHERE ([Username] = @Username)"
UpdateCommand="UPDATE [Student] SET [CurrentSchoolID] = @CurrentSchoolID, [Gender] = @Gender, [Fname] = @Fname, [Lname] = @Lname, [ParentCarer] = @ParentCarer, [StAddress] = @StAddress, [suburb] = @suburb, [postCode] = @postCode, [DOB] = @DOB, [homePhone] = @homePhone, [MobilePhone] = @MobilePhone, [WorkPhone] = @WorkPhone, [email] = @email, [UserID] = @UserID, [Username] = @Username WHERE [StudentID] = @StudentID">
<DeleteParameters>
<asp:Parameter Name="StudentID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="CurrentSchoolID" Type="Int32" />
<asp:Parameter Name="Gender" Type="String" />
<asp:Parameter Name="Fname" Type="String" />
<asp:Parameter Name="Lname" Type="String" />
<asp:Parameter Name="ParentCarer" Type="String" />
<asp:Parameter Name="StAddress" Type="String" />
<asp:Parameter Name="suburb" Type="String" />
<asp:Parameter Name="postCode" Type="Int32" />
<asp:Parameter DbType="Date" Name="DOB" />
<asp:Parameter Name="homePhone" Type="String" />
<asp:Parameter Name="MobilePhone" Type="String" />
<asp:Parameter Name="WorkPhone" Type="String" />
<asp:Parameter Name="email" Type="String" />
<asp:Parameter Name="UserID" Type="Int32" />
<asp:Parameter Name="Username" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:SessionParameter Name="Username" SessionField="Username" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="CurrentSchoolID" Type="Int32" />
<asp:Parameter Name="Gender" Type="String" />
<asp:Parameter Name="Fname" Type="String" />
<asp:Parameter Name="Lname" Type="String" />
<asp:Parameter Name="ParentCarer" Type="String" />
<asp:Parameter Name="StAddress" Type="String" />
<asp:Parameter Name="suburb" Type="String" />
<asp:Parameter Name="postCode" Type="Int32" />
<asp:Parameter DbType="Date" Name="DOB" />
<asp:Parameter Name="homePhone" Type="String" />
<asp:Parameter Name="MobilePhone" Type="String" />
<asp:Parameter Name="WorkPhone" Type="String" />
<asp:Parameter Name="email" Type="String" />
<asp:Parameter Name="UserID" Type="Int32" />
<asp:Parameter Name="Username" Type="String" />
<asp:Parameter Name="StudentID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
C# コード:
protected void Page_Load(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
if (!Page.IsPostBack)
{
if (User.IsInRole("Student"))
{
MultiView1.ActiveViewIndex = 2;
}
else if (User.IsInRole("Staff"))
{
MultiView1.ActiveViewIndex = 6;
}
else if (User.IsInRole("Admin"))
{
MultiView1.ActiveViewIndex = 7;
}
}
}