DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2008
    Posts
    2

    updating db records with DetailsView bound to a tree view control- possible?

    My scenarioo:
    ASP.NET 2.0 , MS SQL Server 2005

    I implemented an N-Level Tree View control that pulls the data from an SQL Server 2005 self-referencing table
    that contains dynamically changing information about ~200 repots and the folders that are located in. The data in the table is
    quasi-xml: all entities in the table have ItemID, child nodes [subfolders and reports names] have ParentID. The hierarchy is 5
    levels deep.

    I'm currently able to navigate on-demand thru the Tree View to the the Report Names that are the leaf nodes of the tree [they have
    no children].

    Next I'd like to implement Details View control bound to the Tree View in order to display one attribute of the report name -
    its description that belongs to the same row in the SQL table as the report name itself. Also I'd like to be able to Edit the
    Description of a report using the Detail View and Save the changes to the database. Before I delve further into the project, I'd
    like ot ask you a high-level Question:

    Q: Is it possible to do with Details View control bound to the Trtee Vew, Or not? If not, what other strategy can I use?

    Thanks for your time,

    Sergei Z

  2. #2
    Join Date
    Jul 2008
    Posts
    1

    Heirachical Data display

    Hi,

    there is no possibility of binding details view to tree view.

    it requires a data source,where treeview cant be a data source of details view...

    if u want to display parent and child nodes level.....

    i have one code which can help u out atleast til some point....

    create a child parent relationship table in ur database....

    in your stored procedure craete a temporary level...

    and till ur dept level 5 just insert data into ur temp table....

    in aspx code .. u need to just give margin for each and every level...

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,649
    Welcome to DevX

    This treeview control does support binding. Hope that helps.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  4. #4
    Join Date
    Jul 2008
    Posts
    2
    Shru and Hack,

    thank you very much for your feedback!. Hack, thanks for welcomimg me to the forum!

    I was able to resolve the problem by binding DetailsView to the Tree View by passing a parameter [a SeleltedNode Value in TreeView] to the DetailsView's SQLDataSource. The code is below: it was partly auto-generated after I configured SQLDataSOurce's query with a parameter coming from the other Control - TreeView.

    ---DETAILSVIEW
    Code:
    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
            AutoGenerateEditButton="true">
            
                <Fields>
                    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                </Fields>
            </asp:DetailsView>
    --SQLDATASOURCE
    Code:
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=LEON-VMSQLRPT;Initial Catalog=ReportServer;User ID=sa;Password=*******;"
                SelectCommand="select  [Name],description
                                    FROM Catalog_RPT where cast(itemID as varchar(36)) = @ItemID"
                UpdateCommand ="Update Catalog_RPT set Description = @Description Where cast(itemID as varchar(36)) = @ItemID">
                
                <SelectParameters>
                    <asp:ControlParameter ControlID="TreeView1" Name="ItemID" PropertyName="SelectedValue"
                        Type="String" />
                </SelectParameters>
                
                 <UpdateParameters>
                    <asp:ControlParameter ControlID="TreeView1" Name="ItemID" PropertyName="SelectedValue"
                        Type="String" />
                </UpdateParameters>
                
            </asp:SqlDataSource>
    Last edited by Hack; 07-18-2008 at 11:01 AM. Reason: Added Code Tags

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,649
    Thanks for coming back and posting your solution.

    It could help others with the same, or similiar problem.

    FYI: I edited your post and added [code]your code goes here[/code] tags around your code as it makes it a bit easier to read.

    Thanks again.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. DRAG COPY in tree view control in asp.net
    By alok.mahajan in forum ASP.NET
    Replies: 5
    Last Post: 06-02-2008, 02:38 AM
  2. Replies: 0
    Last Post: 06-24-2007, 11:51 PM
  3. ListView control to view DBF files
    By badascan in forum VB Classic
    Replies: 1
    Last Post: 06-05-2007, 10:52 AM
  4. Updating Access db from ASP.NET2 server control
    By joe baxter in forum ASP.NET
    Replies: 1
    Last Post: 03-20-2006, 08:30 AM
  5. Web Forms - Tree View Server Side Control
    By Bruce in forum ASP.NET
    Replies: 0
    Last Post: 08-16-2000, 11:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links