0

リンクボタンを使用してグリッド行を削除するための私のコードは次のとおりですが、ページの更新後に削除されたデータをクリックした後、ページを更新せずにページ上のデータを削除したいのですが、更新パネルをグリッドに配置します ここに私のコードがあります

protected void gvContent_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if(e.CommandName=="modify")
    {
        GridViewRow row = 
            (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

        // this find the index of row:
        int RowIndex = row.RowIndex; 

        //this store the  value in varName1:
        int id = Convert.ToInt32(
                   ((Label)row.FindControl("lblContentId")).Text.ToString()); 

        Response.Redirect("ContentManage.aspx?ContentId=" +Convert.ToInt32(id));
    }
    if (e.CommandName == "delete")
    {
        GridViewRow row = (GridViewRow)
                           (((LinkButton)e.CommandSource).NamingContainer);

        // this finds the index of row:
        int RowIndex = row.RowIndex; 

        //this stores the  value in varName1:
        int id = Convert.ToInt32(
                   ((Label)row.FindControl("lblContentId")).Text.ToString()); 

        Content_Data.DeleteContentDetails(id);
        BindGrid();
        UpdatePanel1.Update();
    }
4

2 に答える 2

0

You would need to register gvContentas an async post-back control using the followin

 void Page_Load()
    {
        if (!IsPostBack)
        {
            ScriptManager1.RegisterAsyncPostBackControl(gvContent);
        }

    }

This will cause your Grid to do async post-backs.

Hope that helps

于 2013-04-04T11:06:03.673 に答える