سؤال

I have a GridView like the one below:

<asp:GridView ID="grdProjects" runat="server" />
<Columns>
<asp:BoundField DataField="proLeadName" SortExpression="proLeadName" HeaderText="???" />

I would like to set BoundField's HeaderText attribute value from code behind. Is it possible?

هل كانت مفيدة؟

المحلول

You can do it by the index of the Columns collection, like this:

grdProjects.Columns[0].HeaderText = "Your Text Here";

Note: Obviously, adjust the index value for whatever column you need it to be. Also, do this before you DataBind() the grid.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top