Avatar of KavyaVS
KavyaVS
 asked on

GridView CommandField Button is not firing

It is for .NET 3.5 web application.
I am using asp:CommandField in the GridView for updating the GridView rows.It is working fine in the local machine.
When it published on the server the CommandField button is not firing.

What might be the possible reasons. How to fix it.

Thanks
ASP.NETC#

Avatar of undefined
Last Comment
KavyaVS

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
MajorBigDeal

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Kamal Khaleefa

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
KavyaVS

ASKER
gv1_RowEditing event gets fired when CommandField button gets clicked.I am rebinding the data here.
 protected void gv1_RowEditing(object sender, GridViewEditEventArgs e)
        {
           
            gv1.EditIndex = e.NewEditIndex;
            BindGrid();
        }

I am using the RowDataBound event in GridView.In the GridView RowDataBound event I am enabling CommandField edit button based on user authorization.
   protected void gv1_RowDatabound(object sender, GridViewRowEventArgs e)
        {
            GridViewRow gRow = e.Row;    
            if (gRow.RowType == DataControlRowType.DataRow)
            {
                DataRowView drv = (DataRowView)e.Row.DataItem;
             
                if (IsAuthorized)
                {
                    gRow.Cells[2].Enabled = true;
                }

                else
                {
                    gRow.Cells[2].Enabled = false;
                }

            }


        }

The GridView RowDataBound event is firing each time button is clicked(I am rebinding the Grid in each button click)
How to make RowDataBound event get fired only on Page_Load if (!PostBack) condition satisfied.

Is it because GridView RowDataBound event code the CommandField Update and Cancel buttons are not showing when CommandFiled clicked.

Thanks
jitendra patil

try removing your bindgrid() function from the gv1_RowEditing event.
KavyaVS

ASKER
I removed the bindgrid() function from the gv1_RowEditing event.  Then it is not showing the
Update and Cancel buttons and also the controls not turned into editable Text Boxes.
Thanks
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Kamal Khaleefa

Hi
Try to add the condition if row data type=datarow
To gv row data bound
SOLUTION
jitendra patil

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
KavyaVS

ASKER
Thanks