amillyard
asked on
"cannot convert from 'object' to 'string'"
Development platform : c# asp.net 2.x, iis 6
I am getting a compiler error as follows:
"cannot convert from 'object' to 'string'"
for the line: return bool.Parse(ViewState["_isC hecked"];
your time and efforts with this enquiry are much apprieated.
many thanks.
I am getting a compiler error as follows:
"cannot convert from 'object' to 'string'"
for the line: return bool.Parse(ViewState["_isC
your time and efforts with this enquiry are much apprieated.
many thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Mikkk,
ok, thanks. have updated scripting, am geting the following compiling error message as follows:
'object' does not contain a definition for .value (blue underline for .value)
ok, thanks. have updated scripting, am geting the following compiling error message as follows:
'object' does not contain a definition for .value (blue underline for .value)
ASKER
@Limbeck
thank you for your contribution also.
the : return bool.Parse((string)ViewSta te["_isChe cked"]); is compiling ok -- am just checking function itself is doing what I am hoping it should be achieving...
thank you for your contribution also.
the : return bool.Parse((string)ViewSta
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Mikkk - I had to add the " ", in order to compile -- am checking functionality to confirm the script is performing as expected.
return (ViewState["_isChecked"]== "true");
return (ViewState["_isChecked"]==
ASKER
In the calling procedure - I am using :
protected void Page_PreRender(object sender, EventArgs e)
{
ViewState["_isChecked"] = RadioButton_Role.Checked;
if (ViewState["_isChecked"] )
{
RadioButton_Role.Checked = false;
RadioButton_StaffMember.Ch ecked = true;
}
}
i.e. to check the Radio Button checked status (historic user interation changes to button status) and reconfigure on a PreRender request.
the line :
if (ViewState["_isChecked"]) is not compiling -- a casting error.
what I am trying to check if the state is true or false ... what I am doing wrong here please?
__updated procedure_________________ __________ ___
public bool _isChecked
{
get
{
if (ViewState["_isChecked"] == null)
{
return false;
}
else
{
return (ViewState["_isChecked"] == "true");
//return bool.Parse((string)ViewSta te["_isChe cked"]);
}
}
set
{
ViewState["_isChecked"] = value;
}
}
protected void Page_PreRender(object sender, EventArgs e)
{
ViewState["_isChecked"] = RadioButton_Role.Checked;
if (ViewState["_isChecked"] )
{
RadioButton_Role.Checked = false;
RadioButton_StaffMember.Ch
}
}
i.e. to check the Radio Button checked status (historic user interation changes to button status) and reconfigure on a PreRender request.
the line :
if (ViewState["_isChecked"]) is not compiling -- a casting error.
what I am trying to check if the state is true or false ... what I am doing wrong here please?
__updated procedure_________________
public bool _isChecked
{
get
{
if (ViewState["_isChecked"] == null)
{
return false;
}
else
{
return (ViewState["_isChecked"] == "true");
//return bool.Parse((string)ViewSta
}
}
set
{
ViewState["_isChecked"] = value;
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@p_davis : worked 1st time -- thank you
ASKER
@Mikkk, @Limbeck -- thank you both for your contributions :-)
your welcome
glad to be of help :)
Ed.
Ed.
ASKER
public bool _isChecked
{
get
{
if (ViewState["_isChecked"] == null)
{
return false;
}
else
{
return bool.Parse(ViewState["_isC
}
}
set
{
ViewState["_isChecked"] = value;
}
}