Hook into the ItemDataBound event of the datagrid, then:
Label lbl = (Label)e.Item.FindControl("Label3")
if (lbl != null){
lbl.Text = ((DataRowView)e.Item.DataItem)["OtherColumn"]
}
DataItem actually returns an object which will be a DataRowView when binding
to a dataset/datatable/datarow...looks like you are binding to a custom
collection in which case it'll return your collection item type:
lbl.Text = ((YourClassEntity)e.Item.DataItem).YourProperty
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Craig" <Cr**********@hotmail.com> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
How do I programmatically change the text property of a label in an
ItemTemplate in a datagrid?
Specifically the Text property. I want to change the databinding to
another column at runtime.
<asp:TemplateColumn HeaderText="Rate1">
<ItemTemplate>
<asp:Label runat="server" Text='<%# fRate(DataBinder.Eval(Container,
"DataItem.RateAgentID")) %>' ID="Label3" NAME="Label3">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
Thanks