查找控件文本(ASP.NET/C#)
尝试提取由SQL数据库动态填充的标签的文本值。任何帮助都将不胜感激 ASP.NET查找控件文本(ASP.NET/C#),c#,asp.net,C#,Asp.net,尝试提取由SQL数据库动态填充的标签的文本值。任何帮助都将不胜感激 ASP.NET FindControl将返回一个控件(控件类型),因此需要将其强制转换为标签才能访问Text属性 尝试: <asp:Label ID="PlatformName" Text='<%# DataBinder.Eval(Container.DataItem, "PlatformName") %>' runat="server" /> string strPlatform = GameGrid
FindControl将返回一个控件(控件类型),因此需要将其强制转换为标签才能访问Text属性 尝试:
<asp:Label ID="PlatformName" Text='<%# DataBinder.Eval(Container.DataItem, "PlatformName") %>' runat="server" />
string strPlatform = GameGrid.Rows[counter].FindControl("PlatformName").ToString()
Label lbl = GameGrid.Rows[counter].FindControl("PlatformName") as Label;
if (lbl != null)
strPlatform = lbl.Text;