我是新手,所以请任何人给我一个带有 CRUD 操作的 Asp.net 详细视图控件的示例,该控件内置在详细视图中。如果你不明白我,请回复我。
我正在尝试这个,
<asp:DetailsView ID="DetailsView1" AutoGenerateRows="false" runat="server" OnItemUpdating="update"
OnModeChanging="mode">
<Fields>
<asp:BoundField DataField="PrName" HeaderText="Name" />
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />
<asp:CommandField UpdateText="Update" CancelText="Cancel" DeleteText="Delete" />
</Fields>
</asp:DetailsView>
protected void mode(object sender, DetailsViewModeEventArgs e)
{
if (DetailsView1.CurrentMode == DetailsViewMode.ReadOnly)
{
DetailsView1.ChangeMode(DetailsViewMode.Edit);
FileUpload fl = new FileUpload();
BindPropertyList();
fl = (FileUpload)DetailsView1.FindControl("FileUpload1");
}
else
{
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
BindPropertyList();
}
}
protected void update(object sender, DetailsViewUpdateEventArgs e)
{
TextBox t1 = new TextBox();
t1 = (TextBox)DetailsView1.Rows[0].Cells[1].Controls[0];
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
BindPropertyList();
}
protected void delete(object sender, DetailsViewDeleteEventHandler e)
{
}
我正在使用此代码,但我没有更新点击事件工作,但其他工作正常