rendering the value in radiobuttonlist control
-
Hi! I am having a strange error. I have two same application with two same database running in two different server. The code to render radiobuttonlist in both application was rdoPSWPriority.SelectedValue = DSInfo.Tables(0).Rows(0)(23).ToString DSInfo is a datatable where there is no value present in this record one of my server works fine while another server gives me error like NumberSystem.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. at System.Web.UI.WebControls.ListControl.set_SelectedValue(String value) at Inspections.inspection.Page_Load(Object sender, EventArgs e) in .... and stops to run the code I just couldnt figure out what might be causing this problem I can do sumthing like If DSInfo.Tables(0).Rows(0)(23).ToString <> Nothing Then rdoPSWPriority.SelectedValue = DSInfo.Tables(0).Rows(0)(23).ToString End If but there are like hundreds of radio button so i am just being lazy please help
-
Hi! I am having a strange error. I have two same application with two same database running in two different server. The code to render radiobuttonlist in both application was rdoPSWPriority.SelectedValue = DSInfo.Tables(0).Rows(0)(23).ToString DSInfo is a datatable where there is no value present in this record one of my server works fine while another server gives me error like NumberSystem.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. at System.Web.UI.WebControls.ListControl.set_SelectedValue(String value) at Inspections.inspection.Page_Load(Object sender, EventArgs e) in .... and stops to run the code I just couldnt figure out what might be causing this problem I can do sumthing like If DSInfo.Tables(0).Rows(0)(23).ToString <> Nothing Then rdoPSWPriority.SelectedValue = DSInfo.Tables(0).Rows(0)(23).ToString End If but there are like hundreds of radio button so i am just being lazy please help
This is not null error. See the exception: ArgumentOutOfRangeException The value which you want to select by using rdoPSWPriority.SelectedValue = DSInfo.Tables(0).Rows(0)(23).ToString in buttonlist is not present. Try to get the data which is filling buttonlist and then check the value which you are assigning is present in that data. I think this might help you
Regards, Akhilesh Yadav
-
This is not null error. See the exception: ArgumentOutOfRangeException The value which you want to select by using rdoPSWPriority.SelectedValue = DSInfo.Tables(0).Rows(0)(23).ToString in buttonlist is not present. Try to get the data which is filling buttonlist and then check the value which you are assigning is present in that data. I think this might help you
Regards, Akhilesh Yadav
-
I mean this happens only when no value is selected. and it was woring fine in one server even when i dont select any value but in another server it gives me taht exception
try changing your query. B'coz since there is null while you asssing it gives this exception. Do following changes: 1. In your dropdown list give a default which will get selected if there is not selection. 2. Change your query, if query returns null value for 23rd col then change it to the default selection value of dropdown list. for e.g. if it oracle you can change nvl(tbl.colname,0) here 0 is the value of default selection in dropdown list. Hope it helps you
cheers, Akhilesh Yadav