c# - Substring values into multiple textboxes -
i want seperate multiple values gridview control , show in 4 textboxes. possible? right value: 
with code:
var lblref = new label { text = ((label) row.findcontrol("labelassignmentreference")).text }; string valuetextbox = lblref.text; int indexofrefswe = valuetextbox.indexof(",", stringcomparison.ordinal); string valueref = valuetextbox.substring(0, indexofrefswe); textboxreference.text = valueref; but how in multiple values? ` textboxreference.text = valueref;
textboxrefphone.text = "??"; textboxrefemail.text = "??"; textboxrefdesc.text = "??";`
this should started.
string[] splits = lblref.text.split(','); console.writeline(splits[0]); // refname console.writeline(splits[1]); // 08712332 console.writeline(splits[2]); // ref@gmail.com console.writeline(splits[3]); // refdescription i suggest adding validation checks make sure don't errors, such checking splits.length == 4 expected.
note spaces included in beginning of last 3 elements of splits. can eliminate using trim method, or providing array of delimiters new[] {',', ' '} split function , ignore empty elements (there's overload that).
Comments
Post a Comment