Is there a significance performance issue with changing Gridview *BoundFields* into TemplateFields with Labels? (please see code excerpts below)
I'm planning to implement the change above due to a lot of requirement changes with the gridview fields, to make the code much more easier to maintain. Less code change is required when fields are just rearranged.
Using BoundFields seems more error prone, since one has to be very careful to keep track of all the occurrence of cell indexes. Especially with Gridviews with a lot of fields that are accessed all over the place.
Any help/advice is appreciated.
Thanks in advance.
LABEL:
On Page:
<asp:TemplateField HeaderText="Field1">
<ItemTemplate>
<asp:Label ID="lblField1" runat="server" Text='<%# Eval("Field1")%>' />
</ItemTemplate>
</asp:TemplateField>
In Code:
Label lblField1 = row.FindControl("lblField1") as Label;
if (lblField1 != null) { string field1 = lblField1.Text; }
BOUNDFIELD:
On Page:
<asp:BoundField DataField="Field1" HeaderText="Field1" />
In Code:
string field1 = row.Cells[2].Text;