Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 634811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:20:10+00:00 2026-05-13T20:20:10+00:00

I designed a user control. It contains a public property CurrentValue. When I try

  • 0

I designed a user control. It contains a public property “CurrentValue”.
When I try to initialize the property using an Eval expression, a null value is assigned.

// In below code, label assignment is OK, RatingNull user control assignment get null

<asp:TemplateField>
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Difficulty") %>'
        <uc1:RatingNull ID="RatingNull1" runat="server" CurrentValue='<%# Eval("Difficulty") %>' />
    </ItemTemplate>

If I directly assigned a value (ie, CurrentValue=”5″), user control works fine.

public partial class RatingNull : System.Web.UI.UserControl
{
    private string _CurrentValue;

    public string CurrentValue
    {
        get { return _CurrentValue; }
        set { _CurrentValue = value; }
    }
    (...)
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:20:10+00:00Added an answer on May 13, 2026 at 8:20 pm

    The following code works for me. When do you use _CurrentValue field?

    UserControl

    public partial class Test1 : System.Web.UI.UserControl
    {
    
        public string CurrentValue
        {
            get { return (string)ViewState["CurrentValue"] ?? string.Empty; }
            set { ViewState["CurrentValue"] = value; }
        }
    
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);
    
            writer.Write(this.CurrentValue);
        }
    
    }
    

    Page

    protected void Page_Load(object sender, EventArgs e)
    {
        var ds = new[]
        {
            new { FirstName = "F1", LastName = "L1" },
            new { FirstName = "F2", LastName = "L2" },
        };
    
        DataList1.DataSource = ds;
        DataList1.DataBind();
    }
    

    Html Markup

    <asp:DataList ID="DataList1" runat="server">
        <ItemTemplate>
            <uc1:Test ID="Test1" runat="server" CurrentValue='<%# Eval("FirstName") %>' />
        </ItemTemplate>
    </asp:DataList>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 538k
  • Answers 538k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're drawing on your graphics area, so g.drawString(...) draws a… May 17, 2026 at 2:02 am
  • Editorial Team
    Editorial Team added an answer As long as you've told Google about the sitemap, they'll… May 17, 2026 at 2:02 am
  • Editorial Team
    Editorial Team added an answer I used to get that. I forget which of the… May 17, 2026 at 2:02 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I create my own user control which only contains a panel : When I
I have a property of type IEnumerable<SomeClassIWrote> in a user control. When I use
I am designing a WPF user control which contains other user controls (imagine a
In one of the user controls in our project we have an obsolete property
I have an odd situation with a user control in VS 2010. The form
I'm writing a custom control and I want to add a MessageText property of
i have a simple usercontrol with following properties: public partial class RichTextEditorControl : UserControl
I have some WebUserControls that take a parameter to determine how they initialize themselves.
I have a web page with a GridView. The GridView contains a list of
I have an interesting problem. I've created a WPF UserControl which contains a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.