Last post Aug 18, 2011 09:47 PM by Decker Dong - MSFT
Aug 16, 2011 05:08 PM|wangxg26|LINK
I want to populate data value from Datalist from code behind and send this string value to a label (CityStateidLabel). When I use this label text as a parameter for ODS (object datasouce), it throws error as input string was not in a correct format.
cityID = (Util.FindControlRecursively("cityidLabel2",
CityStateidLabel.Text = cityID;
Aug 16, 2011 05:20 PM|Shuvo Aymon|LINK
cityID. from the name it sounds like integer. if so then is your cityIDLabel2.text is integer? Is it null? please check. the error message means the value you are supplying is not what it should be.
Aug 16, 2011 06:15 PM|wangxg26|LINK
I tested my code again. It seems that the following code isn't correct. I want to get cityId from a DataList02. any suggestion to correct this?
Aug 17, 2011 10:56 PM|Decker Dong - MSFT|LINK
But what's Util?
You haven't told us....
Aug 18, 2011 09:06 PM|wangxg26|LINK
Here is Util. I used it in other situation, it works correctly.
(controlID == null || controls ==
(c.ID == controlID)
inner = FindControlRecursively(controlID, c.Controls);
(inner != null)
Aug 18, 2011 09:47 PM|Decker Dong - MSFT|LINK
OK, I took the meaning of your funciton....
And now let's switch back to your problem……
So Your codes:
string cityID = (Util.FindControlRecursively("cityidLabel2",
Looks like right, But you say it's wrong....
I suspect whether the method has really found the controls or not?
Text should be type of String, there shouldn't be such an error of converting...