So I needed a way to change the DataField property of the first column in a gridview. The situation was that instead of this text when I click this button I want it to show this text. So I added a link button outside the gridview and this was the code inside the onclick event
Dim obj As System.Web.UI.WebControls.BoundField = gridView1.Columns(0)
If obj.DataField = "COLUMN_1" Then
obj.DataField = "COLUMN_2"
Else
obj.DataField = "COLUMN_2"
End If
gridView1.DataBind()
This turned out working perfect for dynamically changing the datafield property in a gridview. I'm sure this could have been done with some sort of javascript or AJAX, but I needed a quick solution and this was it.
2d210302-160f-4230-8878-7e1697a3b477|2|5.0
ASP.NET
gridview, asp.net