第一段代码摘自ASPX页面:
<telerik:RadGrid runat="server" Width="60%" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Top" HeaderStyle-Width="60%" ID="commentRadGrid" AllowFilteringByColumn="False" AutoGenerateColumns="false"
AllowPaging="true" OnNeedDataSource="someRadGrid" PageSize="100" Skin="Default" AllowSorting="true" AutoPostBack="true" ShowStatusBar="true" AllowCustomPaging="True"
GridLines="none" EnableEmbeddedSkins="false" >
<MasterTableView Width="100%" AutoGenerateColumns="false" AllowFilteringByColumn="False" GridLines="none">
<ItemStyle Wrap="true" Width="60%"/>
<Columns>
blah blah blah
<telerik:GridTemplateColumn Visible="false" AllowFiltering="false">
<ItemTemplate>
<asp:Label ID="invisibleSectionResourceDatabaseIDLabel" runat="server" Text='<%# Eval("SectionBasedResourceDatabaseIDAsString")%>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
blah blah blah
</Columns>
</MasterTableView>
<ItemStyle HorizontalAlign="left" />
</telerik:RadGrid>
我正在尝试在运行时创建Label,并在运行时配置Label的属性:
invisibleSectionResourceDatabaseIDLabel = new Label();
invisibleSectionResourceDatabaseIDLabel.ID = colname;
invisibleSectionResourceDatabaseIDLabel.Text =
我不知道如何将invisibleSectionResourceDatabaseIDLabel.Text值设置为&lt;%#Eval(“SectionBasedResourceDatabaseIDAsString”)%&gt;的等效C#代码。在运行时在C#中表达。
请帮我在运行时设置invisibleSectionResourceDatabaseIDLabel.Text值
答案 0 :(得分:1)
invisibleSectionResourceDatabaseIDLabel.Text = DataBinder.Eval(yourBindingObject, "SectionBasedResourceDatabaseIDAsString).ToString();