我有一個數據綁定到gridview的對象列表。 gridview有一個連接到該行的刪除按鈕。在gridview中禁用buttonfields/commandfield的回傳
我需要的對象列表,通過點擊堅持(好像脫機工作) 我不希望使用會話或cookie或viewstates
當前的行爲: 列表中包含了4項=>刪除1項=>列表有3項=>刪除1個項目(回發)列表獲取與4項再生然後刪除1.
class Emails
{
public string Email { get; set; }
public Emails(string _Address)
{
Email = _Address;
}
}
if (!IsPostBack)
{
ListOfEmails = new List<Emails>();
ListOfEmails.Add(new Emails("[email protected]"));
ListOfEmails.Add(new Emails("[email protected]"));
ListOfEmails.Add(new Emails("[email protected]"));
ListOfEmails.Add(new Emails("[email protected]"));
GridView1.DataSource = ListOfEmails;
GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string EmailToBeDeleted = GridView1.Rows[e.RowIndex].Cells[0].Text;
ListOfEmails.Remove(ListOfEmails.Find(L => L.Email == EmailToBeDeleted));
GridView1.DataSource = null;
GridView1.DataSource = ListOfEmails;
GridView1.DataBind();
}
ASPX:
<asp:BoundField DataField="Email" HeaderText="Email Address" />
<asp:ButtonField ButtonType="Button" CommandName="Delete" HeaderText="Action2"
ShowHeader="True" Text="Delete" />
<asp:CommandField ButtonType="Image" DeleteImageUrl="~/delete.gif"
ShowDeleteButton="True" />
「我現在有2個刪除按鈕」
把它們放在updatepanel中? – 2013-03-27 11:00:36
這隻會抑制帖子後退或讓他們不可見我希望禁用它們,直到我明確命令回發。 – AngelicCore 2013-03-27 11:04:04