Changing text of an autogenerated select column of a gridview in asp.net - How?
Solution 1
Use the TemplateField and place into it buttons or linkbuttons with appropriate CommandName property: ButtonField.CommandName Property You may set this button text using DataBinder.Eval method.
Solution 2
after <column>
write this:
<asp:CommandField ShowSelectButton="True" SelectText="Save" />
and remove AutoGenerateSelectButton="True"
from Gridview
attribute.
Solution 3
The easiest way I found to do this is after the calling DataBind() just before the gridview control is displayed.
foreach (GridViewRow row in gvAgreementList.Rows)
{
LinkButton lb = (LinkButton) row.Cells[0].Controls[0];
lb.Text = "Edit";
}
Solution 4
First remove auto generated select then go to GridView
tasks.. top right Button of GridView
and then click on commandfields
-> Select
then edit SelectText
.
(Edited answer of ShaileshK with some changes)
Solution 5
Go to GridVIew tasks.. top right Button of GridView and then click on edit columns In selected fields section Click on select field. change the value of select text. done.
John S
Been around since the days of Business Basic and the 6502. Currently working mostly in the Microsoft stack, C#, SQL, etc.. Also work with SCSS, CSS, JQuery, Javascript. Currently a Software Engineer that likes to keep up on some aspects of the IT side of things so that I can do a better job writing my software. Always striving to understand the whole problem domain not just the algorithm.
Updated on January 10, 2020Comments
-
John S over 4 years
I would like to change the text of the autogenerated
"select"
column in an ASP.NETGridView
control. The text needs to be changed to the value of aDataField
.I suspect that there is a very logical way to do this but I am missing it. I am able to add controls and data via the pre-render event but is there an easier better way?
-
kad81 over 10 yearsThis was the easiest way. Thanks.
-
Zolfaghari over 8 yearsthank you dear BMASolutions, i use this (2 line into loop) in my solution in event GridView_RowDataBound.