我无法解决这个问题,这应该不会太困难。我想从我的数据库或textbox
填充我的label
(标签已经从数据库中提取信息,因此基本上将标签中的内容复制到文本框中)。我正在使用GridView
,这是我一直在尝试的代码:
C#:
for (int i = 0; i < GridView1.Rows.Count; i++)
{
TextBox timeR = GridView1.Rows[i].FindControl("rTime") as TextBox;
Label timeRL = GridView1.Rows[i].FindControl("labelRunScore") as Label;
if (timeR.Text == "")
{
timeR.Text = timeRL.Text;
}
}
的.aspx:
<asp:TemplateField HeaderText = "Run Time">
<ItemTemplate>
<asp:Label ID="labelRunScore" Visible="true" runat="server" Text='<%# Eval("rTime") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Run Time">
<ItemTemplate>
<div style="display:none"> <asp:TextBox ID="rTime" runat="server" type="number" Text='<%# Eval("rTime") %>' ></asp:TextBox></div>
<input onblur="document.getElementById('<%# ((GridViewRow)Container).FindControl("rTime").ClientID %>').value = this.value"
type="number" style="width: 100px; height: 31px;" />
</ItemTemplate>
</asp:TemplateField>