DataGrid - ændre felt på column
Kan man ændre det datafelt en kolone bruger i sin code-behind. Altså ændre denne linie:<%# DataBinder.Eval(Container.DataItem,"fldCount").ToString() %>
Her er et eksempel på hele griden:
<asp:Panel id="Panel6" runat="server">
<DIV align="center"><asp:DataGrid id="oDataGrid6" runat="server" AutoGenerateColumns="False" DataKeyField="fldID" CellPadding="3" GridLines="Vertical" Width="408" BorderWidth="0px" BackColor="White" CssClass="">
<AlternatingItemStyle></AlternatingItemStyle>
<SelectedItemStyle></SelectedItemStyle>
<FooterStyle ForeColor="#FFFFFF" BackColor="#096BFF" />
<HeaderStyle Font-Bold="True" ForeColor="#FFFFFF" BackColor="#8B9EBE" />
<ItemStyle BackColor="#F7F8F9" />
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<asp:Label runat="server" ForeColor="#FFFFFF"><b>Host name</b></asp:Label>
</HeaderTemplate>
<ItemStyle VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"fldHostName") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderTemplate>
<asp:Label runat="server" ForeColor="#FFFFFF"><b>Count</b></asp:Label>
</HeaderTemplate>
<ItemStyle VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem,"fldCount").ToString() %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<P> </P>
</DIV>
</asp:Panel>