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

  • SEARCH
  • Home
  • 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 6344997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:44:25+00:00 2026-05-24T20:44:25+00:00

I am checking some condition in the GridView_RowCommand event. Based on the Condition I

  • 0

I am checking some condition in the GridView_RowCommand event. Based on the Condition I want to set SkinID or remove SkinID for the TextBox.

This is my Code:

if (dt.Rows[0]["D1Variable"].ToString() == "0")
        {
            txtMRVD1.Text = dt.Rows[0]["D1"].ToString();
            txtMRVD1.ReadOnly = true;
            txtMRVD1.SkinID = "txtreadonly";            
        }
        else
        {
            txtMRVD1.Text = "";
            txtMRVD1.ReadOnly = false;
        }

But it throws the following error.

    "The 'SkinId' property can only be set in or before the Page_PreInit event for static controls. For dynamic controls, set the property before adding it to the Controls collection."

How to solve this problem?

  • 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-24T20:44:27+00:00Added an answer on May 24, 2026 at 8:44 pm

    I would say, based on the error message, that you simply need to move that code to the Page_PreInit event.

    However, as MSDN says: “If the request is a postback, the values of the controls have not yet been restored from view state. If you set a control property at this stage, its value might be overwritten in the next event.”

    You may need to get more creative in how you approach this – perhaps storing the information used to determine the skin id in Session. I suggest getting familiar, if you’re not already, with the ASP.NET Page Life Cycle.

    Here’s an example that might work for you, or at least get you pointed in the right direction:

    protected void Page_PreInit(object sender, EventArgs e)
    {
    
        if ((string)Session["D1Variable"] == "0")
        {
            txtMRVD1.SkinID = "txtreadonly";
        }
    }
    

    You can then do the rest of your logic in the GridView RowCommand event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm checking out some PHP 5.3.0 features and ran across some code on the
I need to add some error checking to this function to make sure that
Possible Duplicate: Order of condition checking? When i read some source codes, the if
I'd love some other opinions on what's more efficient in this code. Basically in
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out
I have been checking out some of the possible timers lately, and System.Threading.Timer and
I'm writing some error checking and trying to make use of an boolean array
I use a jquery validation plugin and I need to add some extra checking,
IQueryable<SomeType> collection = GetCollection(); foreach (var c in collection) { //do some complex checking
I've seen some methods of checking if a PEFile is a .NET assembly by

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.