radiobuttonlist
hi,
I have a radiobutton list in gridview with three radiobuttons, text of the radio button which is selected to be inserted in to textbox which is in gridview of next page.
i tried by giving,
session["paid"] = radiobutton1.selecteditem.value.
i have given in next page as,
int paid1;
paid1 = (int)Session["paid"];
but i am getting a runtime error.
plz give me a solution.
is what i had written is wrong?
plz help me.
thanks in advance.
Jaish MathewsPosted May 18, 2010, 4:25 AM
Hi,
Conversion not seems to be a problem as belwo hardcoded line ran correct for me
Session["paid"] = 0;
int paid1;
paid1 = (int)Session["paid"];
So please put break point in below line.
paid1 = (int)Session["paid"];
And before executing this line, see what's the value for "Session["paid"]". I am almost sure it may contain some invalid entry during run time. Just debug and confirm the value in side "Session["paid"]" before executing the above line.
Dipa AhujaPosted May 18, 2010, 3:51 AM
srinathPosted May 18, 2010, 3:30 AM
thanks crish.
i tried that code but i am getting errors like
"The best overloaded method match for 'System.Convert.ToInt32(object)' has some invalid arguments "
"cannot convert from 'method group' to 'object' "
CrishPosted May 17, 2010, 12:37 PM
use below code
int paid1;
paid1 = convert.ToInt(Session["paid"].Tostring());
Don't forget to Mark Do you like this Answer that solved your problem!
srinathPosted May 17, 2010, 9:10 AM
thanks for replying.
i am getting error as
"when casting from a number, the value must be less than infinity"
and
"make sure that source type is convertable to destination type"
here i have give the value for three radiobuttons as 0,1 and 2 respectively.
and i am casting session variable to int as it is an object type .
same as above.
plz help me ..
Jaish MathewsPosted May 17, 2010, 8:46 AM
Hi,
Please check below line that what value stored in Session
session["paid"] = radiobutton1.selecteditem.value
It should be numeric. More over tell that what's your error message.
Dipa AhujaPosted May 17, 2010, 8:40 AM
you have to use as
RadioButton rb=(RadioButton)Gridview1.FindControl("