I’ve got a project that I’ve inherited. I’ve been asked to remove two columns in a GridView on a website and replace them with two other columns. I’ve changed the html to replace the originals with the new ones however the column header names don’t appear to want to change. I’ve run the code with the debugger on and put a break on the first line of the code c# code before it does anything and checked out the gridview object. It already has these column names assigned and I can’t figure out how. I’ve done a search for the original column names and have been unable to find them anywhere.
Basically, my question is what controls what the column is named before the page even really loads? Every time I’ve searched on this I get people wanted to change it programmatically but that doesn’t appear to be what my issue is from what I can tell. I’ve attempted to go into the properties of the object like it was suggested here but it shows the new fields not the old ones.
The following is the relevant (I believe) HTML code which is creating this gridview and object.
<asp:GridView ID="gvTopSearch" runat="server" AllowPaging="True"
AllowSorting="True" PageSize="15" AutoGenerateColumns="False"
DataKeyNames="NID,CID" Width="100%" OnPageIndexChanging="gvTopSearch_PageIndexChanging"
OnSorting="gvTopSearch_Sorting"
onrowdatabound="gvTopSearch_RowDataBound"
meta:resourcekey="gvTopSearchResource1" >
<Columns>
<asp:TemplateField SortExpression="NewField1" HeaderText="NewField1"
meta:resourcekey="TemplateFieldResource5">
<ItemTemplate>
<%#Eval("NewField1")%>
</ItemTemplate>
<HeaderStyle Width="75px" />
</asp:TemplateField>
<asp:TemplateField SortExpression="NewField2" HeaderText="NewField2"
meta:resourcekey="TemplateFieldResource6">
<ItemTemplate>
<%#Eval("NewField2")%>
</ItemTemplate>
<HeaderStyle Width="75px" />
</asp:TemplateField>
</Columns>
<AlternatingRowStyle CssClass="fieldName" HorizontalAlign="Left" />
<EmptyDataTemplate>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" style="padding-top: 50px; padding-bottom: 50px; padding-left: 60px;">
<img src="" alt="" />
<b>
</b>
</td>
</tr>
</table>
</EmptyDataTemplate>
<HeaderStyle CssClass="fieldNamewithbgcolor" HorizontalAlign="Left" />
<PagerStyle CssClass="Paging" />
<RowStyle CssClass="gridbgcolor" HorizontalAlign="Left" />
</asp:GridView>
“NewField1” and “NewField2” are supposed to be displayed but aren’t.
Gah! I hate this stupid project. I’ve found where the issue is finally (it’s only taken about 3 days).
In the same directory there’s apparently an App_LocalResources folder with a resx file in it. In that file are key-value pairs including ones seen above ‘TemplateFieldResource5’ and ‘TemplaceFieldResource6’ and they were linked with the old column names. I’ve changed them to the new column names and it works.
Thanks to those who attempted to help me with your comments. If this is what you meant by the code behind Steve I misunderstood.