Changing text of an autogenerated select column of a gridview in asp.net - How?

余生颓废 提交于 2019-12-29 08:40:09

问题


I would like to change the text of the autogenerated "select" column in an ASP.NET GridView control. The text needs to be changed to the value of a DataField.

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?


回答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.




回答2:


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";
        }



回答3:


after <column> write this:

<asp:CommandField ShowSelectButton="True" SelectText="Save" />

and remove AutoGenerateSelectButton="True" from Gridview attribute.




回答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)




回答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.



来源:https://stackoverflow.com/questions/6232045/changing-text-of-an-autogenerated-select-column-of-a-gridview-in-asp-net-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!