Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
865
How to set the selected imageurl for a particular node using XML Datasource?
posted

Hi,

     I am binding the tree using xmlsource. I want to bind a directory and the corresponding folders and files to the tree. I am getting the details of that directory using a webservice and then stroing that information into a Dataset. Then i am converting that dataset into xmlsource and then binding it to the tree. the following is the design for the treeview in aspx..

 

<ignav:UltraWebTree ID="treedatastore" runat="server" CheckBoxes="True" Height="100%" Width="100%">

<DataBindings>

<ignav:NodeBinding DataMember="treenode" TagField="NavigateUrl" TextField="Text" ToolTipField="ToolTip" ImageUrlField="ImageUrl" />

</DataBindings>

 

</ignav:UltraWebTree>

 

The code in CS

protected const string TREEHEADER = "<?xml version='1.0' encoding='UTF-8'?>";

protected string MAINNODEHEADER = "<treenode Name='MainNode'  ImageUrl='./Images/ig_treeXPFolderOpen.gif' Text='MAINNODEHEADER' >";

protected const string CHILDFOOTER = "</treenode>";

protected string FILESDETAILS = "<treenode Name='CYD'  ImageUrl='./Images/text.gif' Text='FILESDETAILS' ToolTip='TOOLTIP' >";

protected const string TREEFOOTER = "</TREENODES>";

 DataSet ds = new DataSet();

XmlDataSource xmlds1 = new XmlDataSource();

 

private void FillTree(string folder)

{

try

{

DirectoryInfo di = new DirectoryInfo(folder);

retstring = TREEHEADER;

string tempreplace = treeDisplay + GetCustomerDataStoreFolder();

//string tempreplace = AppendPattern(folder,"/");

string tempstr = ReplacePattern("MAINNODEHEADER", tempreplace, MAINNODEHEADER);

retstring += tempstr;

if (di.Exists)

{

retstr += tempstr;

DirectoryInfo[ dir = di.GetDirectories();foreach (DirectoryInfo dis in dir)

{

string tempdir = ReplacePattern("MAINNODEHEADER", dis.Name, MAINNODEHEADER);

retstr += tempdir;

FileInfo[ fi = dis.GetFiles();

 

if (fi.Length > 0)

{

for (int i = 0; i < fi.Length; i++)

{

string fileName = fiIdea.Name.ToString();

long fileSize = fiIdea.Length;

string tempretstr = ReplacePattern("FILESDETAILS", fileName, FILESDETAILS);

string tempFilename = @"File Name:" + fileName + "\nSize:" + fileSize / 1024 + "KB";string temptip = ReplacePattern("TOOLTIP", tempFilename, tempretstr);

retstr += temptip;

retstr += CHILDFOOTER;

}

}

retstr += CHILDFOOTER;

}

retstr += CHILDFOOTER;

xmlds.Data = retstr;

treeDataStore.DataSource = xmlds;

treeDataStore.DataBind();

treeDataStore.ExpandAll();

}

else

{

retstr += CHILDFOOTER;

xmlds.Data = retstr;

treeDataStore.DataSource = xmlds;

treeDataStore.DataBind();

treeDataStore.ExpandAll();

}

catch (Exception ex)

{

}

}

 

It's working fine.. the problem is that when i click on a node the selectedimage shouldnot change. for example if there are folder inside that directory. i will be assigning an image to it and when i click on that node the image should not change at all..but when i click on the node the image is changed even though i have not assigned any image for it. there is no server-side code for the treeview except for binding for the treeview.  can someone tell me how to go about it? or is there anyway to change the image in the client-side?

 Thanks and Regards,

Jollyguy