c# - Looping through to return all the required node IDs -


i kinda struggling returning node id's inside given treeview.

basically have function runs query database using given nodeid , returns parent node id shown below, works fine , returns me parent node id of node id passed through.

public static string parent_id(string nodeid) {            generalconnection gc = connectionhelper.getconnection();    int intnodeid = convert.toint32(nodeid);     querydataparameters para = new querydataparameters();    para.add("@nodeid", intnodeid);     int parent = (int)gc.executescalar("custom.product.searchforparentnodeid", para);     return convert.tostring(parent);               } 

now parentid returned nodeid of node above. want use newly obtained id obtains parentid , keeping looping through table (using above query) till can obtain nodeids within current level. storing these nodeids in stringbuilder list plan on using further checks.

anybody have suggestions?

your question little confusing, maybe help. should try using api instead of custom queries, if possible, make hotfixes/upgrades easier in future. example, if have node id , want of it's siblings, can this:

// version 7 code, untested var treeprovider = new treeprovider(); var childnodeid = 1;  // child node // node id, culture, site name var childnodedataset = treeprovider.selectnodes(childnodeid, null, cmscontext.currentsitename);  if (childnodedataset.items.any()) {     // assuming child node found, parent id     var parentnodeid = childnodedataset.items[0].nodeparentid;      // children of parent, aka siblings     // site name, culture, combine default culture, clause, order clause     var siblingnodes = treeprovider.selectnodes(cmscontext.currentsitename, "/%", null, false, null, "nodeparentid = '" + parentnodeid + "'", null); } 

hope helps.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -