开发者

how to disable all other rows EXCEPT in EDIT mode [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Disable the Edit button on all the rows when Edit button is clicked on a particular row in GridView

how to disable all other rows except the one in EDIT mode?

i am trying to find a way to disable all other row while i am in edit mode of course except the edit one.

here is my gridview looks like:

<gridview.... 
<edittemplate...> 
................ 
</edittemplate> 
............ 
<asp:CommandField ButtonType="Link" ItemStyle-HorizontalAlign="Center" SelectText="Select" 
EditText="Edit" UpdateText="Save" ShowEditButton="true" /> 
</Columns> 
</asp:Grid开发者_如何学运维View> 


You need to handle RowEditing event of GridView to disable all rows except edit one.

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        //Put binding code here..
        GridView1.DataBind();

        foreach (GridViewRow row in GridView1.Rows)
        {
            if (row.RowIndex != e.NewEditIndex)
            {
                row.Enabled = false;
            }
        }
    }

EDIT:

In addition to this code please verify the Page_load method's Binding code.

protected void Page_load()
{
   if(!IsPostBack)
   {
      //put GridView databinding code here

   } 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜