CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 11/22/2007 4:39:42 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 25 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
filipczyk
Asp.Net User
Going nutz trying to display Dataset data in a treeview... help?11/22/2007 4:39:42 PM

0/0

 Hi all, i?ve going completely mad during all morning trying to figure out how to populate a treeview with data from a dataset, and i?ve get very far, but im stuck with an error i cant understand, so maybe you ppl can give me a hand on this one:

 Im working with dnn, wich will explain any "bizarre development behavior", but the issue im confronting its mainly the treeview control (thats why i post my trouble here).

Have a SP wich returns a dataset, wich has 4 columns, all strings, the thing its that i have the 2nd column being   the parent elements of the 3rd column (Ej: Providername(Column2)    ArticleName(Column3)) so the values on the column 2 get repeated N number of times (one for each article that that provider provides).

 
This is the approach im working on:

 

protected void Btn_Click(object sender, EventArgs e)
        {
                ObjectDataSource Cat2=new ObjectDataSource();
                Cat2.SelectMethod="GetCatalogoDS";
                Cat2.DataObjectTypeName = typeof(CatalogoInfo).FullName;
                Cat2.TypeName = typeof(CatalogoController).FullName;
                Cat2.SelectParameters.Add("FamiliaInicial", "10");
                Cat2.SelectParameters.Add("FamiliaFinal", "20");
                 DataView dv = new DataView();
                dv = (DataView)Cat2.Select();
                DataTable dt = dv.ToTable();
                
                
                PopulateNodes(dt, TreeView1.Nodes);
}

private void PopulateNodes(DataTable dt, TreeNodeCollection tree)
    {
        string backup = " ";
        TreeNode tn = new TreeNode();
        foreach (DataRow dr in dt.Rows)
        {

            if (backup != dr.ItemArray[0].ToString())
            {
                
                tn.ChildNodes.Clear();
                tn.Text = dr.ItemArray[0].ToString();
                tn.Value = dr.ItemArray[0].ToString();
                tree.Add(tn);
                backup = tn.Text;
                TreeNode tc = new TreeNode();
                tc.Text = dr.ItemArray[3].ToString();
                tn.ChildNodes.Add(tc);
            }
            else
            {
                TreeNode tc = new TreeNode();
                tc.Text = dr.ItemArray[3].ToString();
               tn.ChildNodes.Add(tc);

            }
        }
  

 And it works... but with only one parent node, the moment i try to add a new node (tree,add(tn))i get a :

System.ArgumentOutOfRangeException was caught
  Message="Index must be within the bounds of the List.\r\nParameter name: index"
  Source="mscorlib"
  ParamName="index"
  StackTrace:
       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       at System.Collections.Generic.List`1.Insert(Int32 index, T item)
       at System.Web.UI.WebControls.TreeNodeCollection.AddAt(Int32 index, TreeNode child)
       at System.Web.UI.WebControls.TreeNodeCollection.Add(TreeNode child)
       at YourCompany.Modules.Catalogo.ViewCatalogo.PopulateNodes(DataTable dt, TreeNodeCollection tree) in c:\Inetpub\wwwroot\DotNetNuke\DesktopModules\Catalogo\ViewCatalogo.ascx.cs:line 207
       at YourCompany.Modules.Catalogo.ViewCatalogo.BtnBicicletas_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\DotNetNuke\DesktopModules\Catalogo\ViewCatalogo.ascx.cs:line 152
 

The code very much explains itself.... i puit the dataset on a datatable and pass it to the PopulateNode procedure, in it i cicle the datatable and for each row, i check the parent node, if it is the first time a parent node appears, i name it and attrach the first child node (cause they belong to the same row), from that moment on, i just add child nodes until the parent node changes...(and in that moment i get the error).

Now, i cant put the treenode definition inside the if clause cause if i do so, i cant add the child node on the else clause, so basically im stuck:S 

 

Any help will be more than welcome.

 

Tnks a lot for your time.

 

Farewell 

zeeshannasir
Asp.Net User
Re: Going nutz trying to display Dataset data in a treeview... help?11/23/2007 5:49:18 AM

0/0

Hi

try following links, it might solve your problem

http://www.informit.com/articles/article.aspx?p=101748&seqNum=12&rl=1

http://www.15seconds.com/issue/041117.htm

http://forums.asp.net/t/7034.aspx 

hope it helps

 


Please Remember to click "Mark as Answer" on this post if it helped you.

Ch. Zeeshan Nasir
ganesansankar
Asp.Net User
Re: Going nutz trying to display Dataset data in a treeview... help?11/23/2007 8:15:15 AM

0/0

Hi,

Refer these links

http://www.codeproject.com/cs/miscctrl/DataBoundTreeView.asp 

http://www.codeproject.com/cs/database/2dtreeview.asp 


Regards
Ganesan S
"Hard Work Never Fails"

Please "Mark as Answered" if helpful for you.
filipczyk
Asp.Net User
Re: Going nutz trying to display Dataset data in a treeview... help?11/24/2007 2:42:29 PM

0/0

HI and thank you both for yor responses and time, i??ve managed to figure a workaround for my trouble, let me post it here so ill help some other ppl as well:

 

private void PopulateNodes(DataTable dt, TreeNodeCollection tree)
        {
            string backup = " ";
            int counter = dt.Rows.Count;
            for (int i = 0; i <= dt.Rows.Count - 1; i++)
            {
                TreeNode tn = new TreeNode();
                tn.Text = dt.Rows[i].ItemArray[0].ToString();
                tn.Value = "Root";
                tn.SelectAction = TreeNodeSelectAction.None;
                tree.Add(tn);
                backup = dt.Rows[i].ItemArray[0].ToString();

                while ((i < counter) && (dt.Rows[i].ItemArray[0].ToString() == backup))
                {
                    TreeNode child = new TreeNode();
                    child.Text = dt.Rows[i].ItemArray[3].ToString();
                    child.Value = dt.Rows[i].ItemArray[1].ToString();
                    tn.ChildNodes.Add(child);
                    i++;
                }
                i--;//cause the first thing that the for does its to increment again, after the i value its already incremented in the while statement

            }

        }
  Tnks all for yor help.... farewell
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Going nutz trying to display Dataset data in a treeview... help ... Going nutz trying to display Dataset data in a treeview... help? Last post 11-24 -2007 9:42 AM by filipczyk. 3 replies. Sort Posts: ...
TheMSsForum.com >> Csharp >> Bug in Decimal.Parse() - The ... The times should display in logged-in user desktop time zone hi, i would be very thankful if u can help me in solving this problem. my problem is i 've a ...
Search Results MLB Gameday 2008: New features in this year's live-data display. ...... interfaces which help a visitor navigate a large data set along various dimensions. ...
pocketpcdeveloper .NET Framework Post pocketpc developer ALETRNATIVE PROGRAM IE TO DISPLAY DATA · pocketpc developer Webrequest + . ...... pocketpc developer fullscreen - going nutz ...
Linux factpack # 1999-Dec-29 # Author: Kimmie Dicaire URL: http://argon.muh-nutz.org argtable => $who, ...... A proxy server that creates easily viewed logs of all data going in or out. ...
Linux factpack # 1999-Dec-29 # Author: Kimmie Dicaire URL: http://logscanner.tradeservices.com log-proxy <=is=> A proxy server that creates easily viewed logs of all data going in or out. ...
Simtel.Net Public Domain, Freeware and Shareware listing NOTE ... Win32/Unix indexes.txt A 1749 991018 How to search and display Simtel. ...... and a study tutorial of BASIC n-b-v301.zip B 653607 980223 Nutz 'n Boltz v3.01 ...
Praktikumsdokumentation Only for direct error messages from Doc. to show inconsistence in the data set . Ò. param error The error message that will display . ...
100 000 words dracula the path of the dragon arma sunt inde mala help ...... nuttall nutte nutten nutter nutters nuttin nutting nutty nutz nutzungsbedingungen nuvo nuxeo ...
263615,731600 specializing,10264,362,1254 graciously,583326,2063 ... ... hayes,1964383758,389456 treeview,1965311619,230,21 force,1965579627,6672 ...... bruner,913093270,309,48 verzonden,925584759,256,92 nutz,939451661,24168 ...




Search This Site:










dnn 3.0.8 sufing from czech republic, menu is not visible

build from the command line

forms authentication and 302 redirects

scrolling messages

unhandled exception page

two sitemaps

a way to use an array on a select statement

.dnn file feature request

(new here) help loading the extended club starter kit

portal [guid] automatically named wrong?

time tracker and issue tracker

updating module setting takes ages

figuring out number of pages in a pdf

nexus dot net nuke 1.0.9 enhancement package problem

ttt forum and smtpmail

working with toolbox

wondering how to copy files about and upload them

using c# strings in your html code

a "forbidden. you were denied access because: access denied by access control list." appears

connection string in the web.config

3.0.13 skins and 3.1

force the client side to refresh

gallery module question

need help on compilation error

inhibiting button when event triggered and uninhibit when event completed

search function

what source sln to open in vs2003

violation of primary key.my summit_user event handler run twice..i dunno y.please help.urgent

how to create news site

upgrade error

 
All Times Are GMT