Take the 2-minute tour ×

Trying to pull the text value of the label that is dynamically populated by a SQL database. Any help would be greatly appreciated!


<asp:Label ID="PlatformName" Text='<%# DataBinder.Eval(Container.DataItem, "PlatformName") %>' runat="server" />

C# Code Behind (Which gives me the object, not the string value in the label)

string strPlatform = GameGrid.Rows[counter].FindControl("PlatformName").ToString() 
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

FindControl will return a control (of type Control), so you will need to cast it to a Label to access the Text property.


Label lbl = GameGrid.Rows[counter].FindControl("PlatformName") as Label;
if (lbl != null)
    strPlatform = lbl.Text;
share|improve this answer
Works great thanks! –  KennyH Nov 11 '10 at 13:48
add comment

Your Answer


