Click here to Skip to main content
15,889,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi members

how i get the column header text when i clicked the gridview Column header

please help

What I have tried:

Protected Sub GridView5_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView5.RowDataBound

       If e.Row.RowType = DataControlRowType.Header Then
           For Each cell As DataControlFieldCell In e.Row.Cells
               cell.Attributes.Add("onclick", "javascript:GetHeaderText('" + cell.Text + "')")
           Next
       End If
   End Sub
Posted
Updated 31-Dec-20 8:56am

1 solution

Make use of the arguments passed to the event.

Click event for specific cell in datagridview vb.net - Stack Overflow[^]
 
Share this answer
 
Comments
Member 14207792 4-Jan-21 4:52am    
how i do that i am still not gettion the clicked header text in gridview
i get it in a popup
 If e.Row.RowType = DataControlRowType.Header Then    
        For Each cell As DataControlFieldCell In e.Row.Cells                                cell.Attributes.Add("onclick", "javascript: GetHeaderText('" + cell.Text + "')")  '           Next      
  End If

   function GetHeaderText(txt) {alert(txt);              
}
Member 14207792 4-Jan-21 4:58am    
i get the header text in popup cause of javascript alert but i want it in variable in vb.net code
because i want use it in sql query after
please help

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