Click here to Skip to main content
15,919,749 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Scheduler Pin
Dave Kreskowiak22-Nov-06 4:26
mveDave Kreskowiak22-Nov-06 4:26 
GeneralRe: Scheduler Pin
Subjugate22-Nov-06 16:48
Subjugate22-Nov-06 16:48 
GeneralRe: Scheduler Pin
Dave Kreskowiak26-Nov-06 15:01
mveDave Kreskowiak26-Nov-06 15:01 
QuestionLocking Database Edit Pin
ONeil Tomlinson21-Nov-06 12:51
ONeil Tomlinson21-Nov-06 12:51 
AnswerRe: Locking Database Edit Pin
leong_wang21-Nov-06 16:33
leong_wang21-Nov-06 16:33 
AnswerRe: Locking Database Edit Pin
Dave Kreskowiak22-Nov-06 4:24
mveDave Kreskowiak22-Nov-06 4:24 
GeneralRe: Locking Database Edit Pin
jsampsonPC22-Nov-06 10:53
jsampsonPC22-Nov-06 10:53 
Questionmaintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
uglyeyes21-Nov-06 12:37
uglyeyes21-Nov-06 12:37 
Hi!

for your convinience i am attaching the below code. I have a treeview web control populated dynamically via a sql server database. environment i am on is (visual studio .net 1.1 and sql server 2000)

each node in a treeview is a hyperlink and below code is for index.aspx.vb

i am filtering a datagrid based upon a tree view node selection which works fine. but when i select the treeview node, the treeview doesnt maintain its state i.e. it collaspe back to its original non expanded view. i searched really hard over the net but i am nothing getting a proper solution. there is no autopostback in my treeview control. All i want to do is maintain the previous treeview control state in a treeview upon navigate URL i.e.
nodeAutoCat.NavigateUrl = "Index.aspx?CatId=" + Server.UrlEncode(CType(rowAutoCat("CatId"), String))


-----
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'initialize the sql connection
objConn = New SqlConnection(dbPath)
'get a ID via NavigateURL of treeview web control
Dim value As String
value = Request.QueryString("CatId")
If value <> Nothing Then
Dim dsProducts As New DataSet
cmd = New SqlCommand("SELECT vehId, vehName, vehImgRef from vehicle where catId ='" + value.ToString + "'", objConn)
Dim daAuto As New SqlDataAdapter(cmd)

'filter the datagrid based on treeview node selected
daAuto.Fill(dsProducts)
dgProducts.DataSource = dsProducts
dgProducts.DataBind()
End If

'populating treeview control
If Not IsPostBack Then

Dim objDS As New DataSet


Dim daAutoType As New SqlDataAdapter("SELECT AutoId,AutoType FROM AutoType", objConn)

Dim daAutoCat As New SqlDataAdapter("SELECT AutoId,CatId, CatName FROM Category", objConn)



daAutoType.Fill(objDS, "dtAutoType")
daAutoCat.Fill(objDS, "dtAutoCat")


objConn.Close()

objDS.Relations.Add("AutoTypeToCat", objDS.Tables("dtAutoType").Columns("AutoId"), objDS.Tables("dtAutoCat").Columns("AutoId"))



Dim nodeAutoType, nodeAutoCat As TreeNode
Dim rowAutoType, rowAutoCat As DataRow


For Each rowAutoType In objDS.Tables("dtAutoType").Rows

nodeAutoType = New TreeNode
nodeAutoType.Text = rowAutoType("AutoType")
nodeAutoType.ID = rowAutoType("AutoId")
TreeView1.Nodes.Add(nodeAutoType)
TreeView1.EnableViewState = True


For Each rowAutoCat In rowAutoType.GetChildRows("AutoTypeToCat")

nodeAutoCat = New TreeNode
nodeAutoCat.ID = rowAutoCat("CatId")
nodeAutoCat.Text = rowAutoCat("CatName")
'add a link to each node.
nodeAutoCat.NavigateUrl = "Index.aspx?CatId=" + Server.UrlEncode(CType(rowAutoCat("CatId"), String))
nodeAutoCat.Expanded = True

nodeAutoType.Nodes.Add(nodeAutoCat)
Next

Next

'clean up
objDS.Dispose()
daAutoType.Dispose()
daAutoCat.Dispose()

objConn.Close()
objConn.Dispose()

End If
End Sub
-----

please help as i didnt get a proper answer from my earlier post

cheers.
AnswerRe: maintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
jsampsonPC21-Nov-06 13:10
jsampsonPC21-Nov-06 13:10 
GeneralRe: maintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
uglyeyes21-Nov-06 13:44
uglyeyes21-Nov-06 13:44 
GeneralRe: maintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
jsampsonPC21-Nov-06 14:02
jsampsonPC21-Nov-06 14:02 
GeneralRe: maintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
jsampsonPC21-Nov-06 14:38
jsampsonPC21-Nov-06 14:38 
GeneralRe: maintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
uglyeyes21-Nov-06 14:50
uglyeyes21-Nov-06 14:50 
AnswerRe: maintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
jsampsonPC22-Nov-06 1:10
jsampsonPC22-Nov-06 1:10 
GeneralRe: maintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
uglyeyes22-Nov-06 5:03
uglyeyes22-Nov-06 5:03 
GeneralRe: maintaining viewstate on microsoft.web.ui.webcontrols.treeview Pin
uglyeyes27-Nov-06 4:12
uglyeyes27-Nov-06 4:12 
AnswerRe: Days in Month Pin
jsampsonPC21-Nov-06 12:14
jsampsonPC21-Nov-06 12:14 
QuestionDays in Month Pin
Cedrickdeorange21-Nov-06 11:48
Cedrickdeorange21-Nov-06 11:48 
AnswerRe: Days in Month Pin
jsampsonPC21-Nov-06 12:13
jsampsonPC21-Nov-06 12:13 
QuestionCapturing a series of keystrokes at any time Pin
jsampsonPC21-Nov-06 11:27
jsampsonPC21-Nov-06 11:27 
AnswerRe: Capturing a series of keystrokes at any time Pin
Leah_Garrett21-Nov-06 17:24
Leah_Garrett21-Nov-06 17:24 
AnswerRe: Capturing a series of keystrokes at any time Pin
Dave Kreskowiak22-Nov-06 4:18
mveDave Kreskowiak22-Nov-06 4:18 
QuestionOLE DB help Pin
rickki21-Nov-06 10:39
rickki21-Nov-06 10:39 
AnswerRe: OLE DB help Pin
Dave Kreskowiak22-Nov-06 4:15
mveDave Kreskowiak22-Nov-06 4:15 
GeneralRe: OLE DB help [modified] Pin
rickki22-Nov-06 7:00
rickki22-Nov-06 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.