c# - Index and length must refer to a location within the string. RAD Treeview -


i have telerik rad treeview & listbox.from server side need when node clicked & if node value 1 disable radlistbox.but exception throws this

index , length must refer location within string.

public void disablelistbox() {     try     {         if (convert.toint32(treeobj.selectedvalue.substring(0,1)) == 1)         {             radlistboxproducts.enabled = false;         }     }     catch (exception ee)     { } } 

it means code

treeobj.selectedvalue.substring(0,1) 

is returning empty string. debug code , place mouse on

treeobj.selectedvalue 

to see returning.

to avoid exception can first check returning string of atleast length 1

if(treeobj.selectedvalue.length > 1)  //assuming selectedvalue returning string {     //your code } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -