|
Thanks Alexei
Can I ask you a favor. I am anyway going to post this message in another forum but maybe you can have a look and see if you see something wrong with it.
Thanks
Steve
Imports System.Data
Imports System.Web.UI.WebControls
Partial Class members_organization_mysampletreeview
Inherits System.Web.UI.Page
Dim memberid As Long
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' THIS IS THE ID OF THE LOGGED IN USER WHICH IS BASICALLY THE ROOT NODE OF THE TREE
memberid = 3
If IsPostBack = False Then
populaterootlevel()
End If
End Sub
Public Sub populaterootlevel()
Dim mycon As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("trafficbobbyconstringaccess").ToString())
Dim mycmd As New OleDb.OleDbCommand
Dim strsql As String
Dim dr As OleDb.OleDbDataReader
Dim NoOfDownline As Integer
'Find out how many child nodes this parent is supposed to have
strsql = "SELECT members.RisingEagleSponsor AS ID, Count(members.RisingEagleID) AS Parent"
strsql = strsql & " FROM(members)"
strsql = strsql & " GROUP BY members.RisingEagleSponsor"
strsql = strsql & " HAVING (((members.RisingEagleSponsor)=" & memberid & " ));"
mycmd.Connection = mycon
mycmd.CommandText = strsql
If mycon.State <> ConnectionState.Open Then
mycon.Open()
End If
dr = mycmd.ExecuteReader
dr.Read()
If dr.HasRows = True Then
NoOfDownline = dr.Item("Parent")
End If
dr.Close()
strsql = "SELECT members.RisingEagleID AS ID, 0 AS Parent, members.MemberName AS Title, " & NoOfDownline & " as childnodecount"
strsql = strsql & " FROM(members)"
strsql = strsql & " WHERE (((members.RisingEagleID)=" & memberid & "));"
mycmd.Connection = mycon
mycmd.CommandText = strsql
If mycon.State <> ConnectionState.Open Then
mycon.Open()
End If
Dim da As New OleDb.OleDbDataAdapter(mycmd)
Dim dt As New DataTable
da.Fill(dt)
mycon.Close()
PopulateNodes(dt, Me.TreeView1.Nodes)
End Sub
Public Sub populatesublevel(ByVal parentid As Integer, ByVal parentnode As TreeNode)
Dim mycon As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("trafficbobbyconstringaccess").ToString())
Dim mycmd As New OleDb.OleDbCommand
Dim strsql As String
'Get the final list of all the downline for this member
strsql = "SELECT members.RisingEagleID AS ID, members.RisingEagleSponsor AS Parent, members.MemberName AS Title, AllParents.childnodecount"
strsql = strsql & " FROM members"
strsql = strsql & " INNER JOIN AllParents ON members.RisingEagleSponsor = AllParents.Parent"
strsql = strsql & " WHERE members.RisingEagleSponsor = " & parentid
strsql = strsql & " ORDER BY members.RisingEagleSponsor"
mycmd.Connection = mycon
If mycon.State <> ConnectionState.Open Then
mycon.Open()
End If
mycmd.CommandText = strsql
Dim da As New OleDb.OleDbDataAdapter(mycmd)
Dim dt As New DataTable
da.Fill(dt)
mycon.Close()
PopulateNodes(dt, Me.TreeView1.Nodes)
End Sub
Public Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodePopulate
On Error GoTo errhandler
populatesublevel(Int32.Parse(e.Node.Value), e.Node)
Errhandler:
Select Case Err.Number
Case 0
Exit Sub
Case Else
Dim mymsg As String
mymsg = Err.Number & " " & Err.Description
End Select
End Sub
Public Sub PopulateNodes(ByVal dt As DataTable, ByVal nodes As TreeNodeCollection)
On Error GoTo errhandler
Dim mymsg As String
For Each dr As DataRow In dt.Rows
mymsg = dt.Rows.Count
Dim tn As TreeNode = New TreeNode()
tn.Text = dr("Title").ToString()
tn.Value = dr("ID").ToString
nodes.Add(tn)
'If node has child nodes then enable on-demand populating
tn.PopulateOnDemand = CType(dr.Item("childnodecount"), Long) > 0
Next
mymsg = "123"
Errhandler:
Select Case Err.Number
Case 0
Exit Sub
Case Else
mymsg = Err.Number & " " & Err.Description
End Select
End Sub
End Class
|
|
|
|
|
I didnt read your code, you didnt mention if it os working or not, so i dont know what to look for
All i can give you is an example i used:
Public Sub FillNode(ByVal ID As Integer, ByRef RootNode As TreeNode)
Dim Node As TreeNode
Dim Rows As DataRow() = Me.tbl.Select("FatherCategoryID=" & ID, "Name")
For Each R As DataRow In Rows
Node = New TreeNode(R.Item("Name"), R.Item("CategoryID"))
Node.SelectAction = Me.SelectAction
Me.FillNode(R.Item("CategoryID"), Node)
RootNode.ChildNodes.Add(Node)
Next
End Sub
For this example, there is a table with all the rows called tbl. The struct for the table is:
CategoryID, FatherCategoryID, Name
And this function is called sending the root node of the treeview and the id of the parent node
I hope this helps you
Alexei Rodriguez
|
|
|
|
|
Thanks - I will give it a try
Steve
|
|
|
|
|
Hi Alexei
Sorry for being a pain in the &%^# but I am still having some difficulty.
I tried the sample you gave me but couldn't get it to work.
Then I tried the following:
While dr_ID.Read
'Find a node matching this node value
Dim Nodx As TreeNode
Dim containernode As New TreeNode
For Each Nodx In Me.TreeView1.Nodes
Nodx.PopulateOnDemand = False
If Nodx.Value.ToString = P.ToString Then
containernode.Value = dr_ID.Item("MembersID").ToString
containernode.Text = dr_ID.Item("MembersName").ToString
Nodx.ChildNodes.Add(containernode)
Nodx.SelectAction = TreeNodeSelectAction.Expand
End If
Next Nodx
End While
It populates the root node as well as the first level of children but it seems that the "For Each Nodx In TreeView" doesn't actually return a reference to the children. Is this true? the "P" that you see is the parentid which the childnode has to be created under whilst the rest is pretty much explanatory.
Can u suggest anything else?
Regards
Steve
|
|
|
|
|
Member 3596900 wrote: If Nodx.Value.ToString = P.ToString Then
I think your comparision is wrong, Set a breakpoint and see whats in each variable
I dont know what P is since your explanation didnt explain it
Alexei Rodriguez
|
|
|
|
|
What would you call the gmail "more actions" menu? Is there an open-source version of that style menu?
Todd Smith
|
|
|
|
|
Todd Smith wrote: What would you call the gmail "more actions" menu?
A customised DropDownList .
Todd Smith wrote: Is there an open-source version of that style menu?
Do you nead one. You could use the existing DropDownList ASP.NET control with AJAX or AutoPostBack set to true to accomplish pretty much the same.
|
|
|
|
|
Hello all. I'm using the asp:FileUpload control to, well, upload a file. I get the data and save it into a local database as a binary. It all works well.
However, I'm having a problem with the Content Type. When selecting a Word document, its content type (FileUpload.PostedFile.ContentType) is "application/octet-stream" rather than "application/msword". This will make my app not behave as expected when the document is retrieved (since I can't state a correct content type so that the document is opened by Word).
The client machine has Word installed, but the server doesn't. Do I have to install Word in the server? I was reading that the Content Type is taken from the client machine, so this shouldn't be a problem. I'm I missing something here? The MSDN documentation doesn't say a thing about the content type.
Thanks in advance.
Stupidity is an International Association - Enrique Jardiel Poncela
Die deutsche Sprache sollte sanft und ehrfurchtsvoll zu den toten Sprachen abgelegt werden, denn nur die Toten haben die Zeit, diese Sprache zu lernen. - Mark Twain
|
|
|
|
|
The asp control is just an input type=file, b/c that's the *only* way that a file can be uploaded from a browser using HTML. I'd suggest you need to work out it's a Word doc from the file extension.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I was thinking the same. However, it wouldn't work for non-common extensions (for instance, there's an app that has its own extension, and so on). If I don't find a better way, I'll have to do it this way.
Thanks for the answer.
Stupidity is an International Association - Enrique Jardiel Poncela
Die deutsche Sprache sollte sanft und ehrfurchtsvoll zu den toten Sprachen abgelegt werden, denn nur die Toten haben die Zeit, diese Sprache zu lernen. - Mark Twain
|
|
|
|
|
What are you trying to do with the file once it's uploaded to your server?
Todd Smith
|
|
|
|
|
It's some sort of document flow, so I store it in a database and many users have to approve/reject it. I need the content type so I can show it to the user by simply writing the binary to the HttpResponse object. I guess I'll have to try something different (Christian's suggestion, most likely).
Thanks.
Stupidity is an International Association - Enrique Jardiel Poncela
Die deutsche Sprache sollte sanft und ehrfurchtsvoll zu den toten Sprachen abgelegt werden, denn nur die Toten haben die Zeit, diese Sprache zu lernen. - Mark Twain
|
|
|
|
|
Can anyone please suggest a few free mail clients library supporting SMTP & POP. written for C# ASP.Net projects?
|
|
|
|
|
How to maintain Seesion in windows application
Rickey
|
|
|
|
|
Windows applications are stateful, therefore there is no need to explicitly store session state like there is in an ASP.NET application (which is stateless).
|
|
|
|
|
I want that if User is not using the application for 20 minutes then he hase to login again.
Rickey
|
|
|
|
|
As he explained that Windows Apps are stateless and does not maintain session, you will need to write custom code for it.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Then you'll have to write some sort of custom logic for that. You could create a class that maintains a "last used" timestamp. Each time your user does something, event calls a method in the class that updates the timestamp. If the method detects that the time now is greater than 20 minutes since the last time, it can initiate the login form - Your application would then be unusable until the user has logged in.
|
|
|
|
|
Hi,
What is the best encryption for saving password in DB?
I need a encryption that can be decrypt it (access real password).
Could you tell me how do it (the encryption thah you'll introduced), please?
Best wishes
|
|
|
|
|
|
use RIJNDAEL...
Its most popular and also good one..
Abhishek Sur
|
|
|
|
|
|
mehrdadc48 wrote: I need a encryption that can be decrypt it (access real password).
That's less secure. For better security you have to use hashing with salt added. Check SHA512Managed or SHA384Managed classes.
|
|
|
|
|
You are better off using a secure cryptographic hash with salt values added to the original password.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have two comboboxes FooBar1 and FooBar2, both store a value retrieved from tbl_FooBar. One of the values in tbl_FooBar is 'All'. If 'All' is selected in one combobox, the value in the second must be null (displayed as 'none'). Can I enforce this using a validator?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|