ASP.NET - Use variable in .aspx page
<p>I'm trying to access a variable or property in my .cs file from the .aspx file but not having any luck.  I've looked at several threads on here and have tried them all but still no luck.  Here's the scenario;  I've got a GridView control with textboxes and a RequiredFieldValidator in one row:</p>

<pre><code>&lt;asp:TemplateField HeaderText="User Name" ItemStyle-Width="10px"&gt;
    &lt;ItemTemplate&gt;
        &lt;asp:Label ID="lblWebLogin" runat="server" Text='&lt;%#Eval("WebLogin") %&gt;'&gt;&lt;/asp:Label&gt;
    &lt;/ItemTemplate&gt;
    &lt;EditItemTemplate&gt;
        &lt;asp:TextBox ID="txtWebLogin" runat="server" Text='&lt;%#Eval("WebLogin") %&gt;'&gt;&lt;/asp:TextBox&gt;
        &lt;asp:RequiredFieldValidator ID="rfvEditWebLogin" runat="server" 
            ControlToValidate="txtWebLogin" Display="None" ErrorMessage='&lt;%= this.LoginRequired %&gt;'&gt;&lt;/asp:RequiredFieldValidator&gt;
    &lt;/EditItemTemplate&gt;
    &lt;FooterTemplate&gt;
        &lt;asp:TextBox ID="txtWebLogin" runat="server"&gt;&lt;/asp:TextBox&gt;
    &lt;/FooterTemplate&gt;
&lt;/asp:TemplateField&gt;
</code></pre>

<p>There is a ValidationSummary control on the form which is working because I can set the ErrorMessage to a literal string and see that it works.</p>

<p>Here's the code from my .cs:</p>

<pre><code>public string LoginRequired
{
    get { return "Error, please try again"; }
}

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
        BindDataToGrid();
}

private void BindDataToGrid()
{
    DataTable dt;
    SqlCommand sc = new SqlCommand();
    DAL oDAL = new DAL(DBInformation.Instance.CurrentEncodedConnectionString, DBInformation.Instance.ConnectionTimeout);

    //Get User Information.
    sc.CommandText = Constants.StoredProcedureNames.GetUsers;
    dt = oDAL.SPDataTable(sc, "AllUsers");
    gvUsers.DataSource = dt;

    foreach (DataRow dr in dt.Rows)
        lUser.Add(new User());

    gvUsers.DataBind();
}
</code></pre>

<p>any ideas as to why it's not working?</p>
