How to know column pressed in a GridView in ASP?

0

I have a GridView in asp from which I would like to know the name or number of the column that you clicked. I'm not interested in the row since I already manage it, I want you to click on the header of a column and from there shoot a function to do something.

Taking advantage of the same thread I also want to know if you click on a specific cell to know which one you have pressed and also to trigger a function.

thanks

    
asked by Xavier Crespo 08.02.2018 в 20:47
source

1 answer

0

Inside your DataGrid, if you are using ASPX with Forms; within the control they also handle events; For your request the event would be: RowCommand
             [e.Row.RowIndex]

    protected void TUDATAGRID_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "TOTAL") //EVALÚAS QUE LA COLUMNA TOTAL  
            {
                  //ACCIONES QUE DESEAS REALIZAR SI HACEN CLICK EN ESA COLUMNA
            }

            if (e.CommandName == "Entrada") //EVALÚAS QUE LA COLUMNA QUE DESEAS  
            {
                  //ACCIONES QUE DESEAS REALIZAR EN OTRA COLUMNA 
            }
}

It works in the following way by clicking on uan Fila_Persona automatically you get the number of the row that you clicked with e. Now what you do in each IF is to evaluate e. Also to know if he clicked on the column that you want ... !!! I leave you a Capture of how I have it Implemented ..

link

    
answered by 09.02.2018 в 19:08