Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends


i have Custom Gridview . i have bind data while i click on Edit mode all data set to text box as Edit Mode.
After that i click to Cancel button, Gridview automatically create textbox inside that.
Here is code for
C#
protected void SmtBranchGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.ToUpper() == "EDIT")
        {
            int Mid = Convert.ToInt32(e.CommandArgument);
            SmtBranchId.Text = Mid.ToString();
            _Status = optype.editordel;
            SmtBranchId.Enabled = false;
            objBAL = new ApplicationLogic();
            objBAL.TypeOfOperation = DBOperation.View;
            objBAL.FetchDataForDBOperation(this);
            SetGridHeaderFix();
            ScriptManager.RegisterStartupScript(this.Page, GetType(), "Javascript", "javascript: ResetScrollPosition(); ", true);
            EnabelOrDisable();
        }
    }



C#
protected void BtnCancel_Click(object sender, EventArgs e)
    {
        objBAL = new ApplicationLogic();
        objBAL.ClearAllControls(Page);
        _Status = optype.insert;
        EnabelOrDisable();
        SmtBranchName.Focus();
        SetGridHeaderFix();
    }


My Grid Open In Edit mode but After click Cancel button gridiview create textbox inside that row which i open as Edit mode.

Please Help me...

Tx To all In Advance
Posted

1 solution

Reset the edit mode of gridview on cancel button click.
Try :
C#
protected void BtnCancel_Click(object sender, EventArgs e)
{
    objBAL = new ApplicationLogic();
    objBAL.ClearAllControls(Page);
    _Status = optype.insert;
    EnabelOrDisable();
    SmtBranchName.Focus();
    SetGridHeaderFix();
    SmtBranchGrid.EditIndex = -1;//Resetting the gridview to original mode.
}



--Amit
 
Share this answer
 
Comments
Yatin chauhan 1-Mar-13 2:07am    
Thx For Reply Amit

I have Done but still textbox created automatically inside gridview row while click cancel button...
_Amy 1-Mar-13 2:10am    
Try putting AutoGeneratedColumn="false" in your gridview.
Yatin chauhan 1-Mar-13 2:36am    
I have Already add AutoGeneratedColumn="false"..
There is some problem i have many field on that grid and me hide some filed which is not neccesory. when i set all field show now its works fine....


Again tx _Amy and Amit....!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900