我想手动设置一些FormView中的控件,一些来自SQL数据源。
以下是我的代码片段:
<asp:FormView runat="server" DataSourceID="ds_Sco_Post_Reference_Data" ID="frmview1">
<ItemTemplate>
<div class="customer-details-inception-date">
<label class="applicationfont">Inception Date:</label>
<asp:TextBox CssClass="smallinputbox" runat="server" ID="txt_customer_details_inception_date" Text='<%# Bind("InceptionDate") %>' />
</div>
<div class="customer-details-renewal-date">
<label class="applicationfont">Renewal Date:</label>
<input class="smallinputbox" runat="server" id="txt_customer_details_renewal_date" readonly="readonly" />
</div>
<div class="customer-details-date-complient-logged">
<label class="applicationfont">Date Complient Logged:</label>
<asp:TextBox CssClass="smallinputbox" runat="server" id="txt_customer_details_date_complient_logged" />
</div>
</ItemTemplate>
</asp:FormView>
我希望能够找到控件txt_customer_details_date_complient_logged
并尝试了很多不同的C#代码。
以下是一个不起作用的示例:
FormView cph = (FormView)this.FindControl("frmview1");
TextBox t = ((TextBox)cph.FindControl("txt_customer_details_date_complient_logged"));
t.Text = DateTime.Now.ToString("d");
有谁知道为什么我不能让这个工作?