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
Post a Comment