Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1443
  • Last Modified:

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
0
KavyaVS
Asked:
KavyaVS
  • 3
  • 2
  • 2
  • +1
3 Solutions
 
MajorBigDealCommented:
First thing I would do is look in the event manager on the server and see if any errors are being thrown. Second thing is to adding logging to narrow down the problem.  For example, is the problem happening before, during, or after the event handler is being called.
0
 
Kamal KhaleefaInformation Security SpecialistCommented:
tryo to trace your code at each point by inserting something into database

ex

sub my button click ......
insertToDB("Enter My Code")

your code
insertToDB("Execute My Code")

also check if you are using ajax that every thing is set and configured
0
 
KavyaVSAuthor Commented:
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
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Jitendra PatilSr.Software EngineerCommented:
try removing your bindgrid() function from the gv1_RowEditing event.
0
 
KavyaVSAuthor Commented:
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
0
 
Kamal KhaleefaInformation Security SpecialistCommented:
Hi
Try to add the condition if row data type=datarow
To gv row data bound
0
 
Jitendra PatilSr.Software EngineerCommented:
you can also check for the commandbutton on the backend code and do your processing, try the below links
GridView.RowCommand Event
How to: Respond to Button Events in a GridView Control
hope this helps.
0
 
KavyaVSAuthor Commented:
Thanks
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now