我正在使用GridView Row命令從Gridview刪除行的事件,我添加了Gridview的RowDeleting事件, 但刪除後,GridView變得隱藏起來。 下面是我的代碼GridView在行刪除事件後隱藏
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack){
LoadData()//Here I am databinding the Grid
}
}
private void LoadData()
{
var data=MyClass.GetRecords();//it returns DataTable
dg.DataSource=data;
dg.DataBind();
}
protected void dg_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if(e.CommandName =="del")
{
//Delete Records
dg.DataBind();
}
}
public void dg_RowDeleting(Object sender, GridViewDeleteEventArgs e)
{
dg.DataBind();
}
你的意思是數據全沒了? –
哪裏是數據源? –
@PandaZhang是的,你可以這樣說,但是當我刷新頁面時,GridView會再次出現 –