开发者

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

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 开发者_Python百科add controls and data via the pre-render event but is there an easier better way?


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.


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


after <column> write this:

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

and remove AutoGenerateSelectButton="True" from Gridview attribute.


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜