CodeSmith Community
Your Code. Your Way. Faster!

error in Bound Radio Button Field control

Latest post 05-19-2008 12:05 PM by vjerko. 0 replies.
  • 05-19-2008 12:05 PM

    • vjerko
    • Top 500 Contributor
    • Joined on 04-27-2008
    • Posts 10
    • Points 80

    error in Bound Radio Button Field control

    Unable to cast object of type 'System.Web.UI.WebControls.RadioButton' to type 'System.Web.UI.WebControls.RadioButtonList'.


    Source Error:

    Line 65:                         checkedValue = ((RadioButton)radio).Checked;
    Line 66:                     else
    Line 67:                         checkedValue = ((RadioButtonList)radio).SelectedValue;
    Line 68:                 }
    Line 69:                 else

    Source File: C:\NetTiers\adriatica\adriatica.Web\UI\BoundRadioButtonField.cs    Line: 67

     Code should go:

    if (radio is RadioButton || radio is RadioButtonList)

    {

    if (rowState == DataControlRowState.Normal || rowState == DataControlRowState.Alternate)

    checkedValue = ((RadioButton)radio).Checked;

    else

    checkedValue = ((RadioButtonList)radio).SelectedValue;

    }

    else

    {

    // A RadioButton is expected, but a null is encountered.

    throw new InvalidOperationException("RadioButtonField could not extract control.");

    }

     

    Filed under: ,
    • Post Points: 5
Page 1 of 1 (1 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems