基本點:
1)您可以打開/關閉GridView和與Panel
2編輯表格)您使用OnRowCommand觸發編輯
3)您有內部的其他按鈕形成觸發保存/取消/關閉
這裏是基本的代碼:
<asp:Panel id="pnlViewList" runat="server">
<asp:GridView ID="gvMyList" OnRowCommand="RowCommand" DataKeyNames="UserId" ..........>
<Columns>
<asp:ButtonField Text="Edit" CommandName="EditMe" />
........rest of your fields.........
</Columns>
</asp:GridView>
</asp:Panel>
<asp:Panel id="pnlEdit" runat="server">
<h2>form edit</h2>
Name : <asp:textbox id="txtName" runat="server" />
........rest of your form.........
</asp:Panel>
和代碼是後來從網格視圖捕獲編輯。
protected void RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditMe")
{
int iTheIndexNow;
if (int.TryParse(e.CommandArgument.ToString(), out iTheIndexNow))
{
gvMyList.SelectedIndex = iTheIndexNow;
// close the gridview, open the form
pnlEdit.Visible = true;
pnlViewList.Visible = false;
// load the form for editing
LoadLineForEditing(gvMyList.SelectedValue.ToString());
}
}
}
你試過搜索嗎? –