|
You don't need to create a class to do what is already available. EnableViewState = true
only two letters away from being an asset
|
|
|
|
|
hi!
enableviewstate is by default made true for treeview control. may be i have misunderstood what you are trying to say. could you please explain me in detail?
originally the page loads as "tree.aspx". each node has its id and value(which is an integer) all i am trying to do is display a datagrid on the left based on the node they select. lets say if they select sub node of id 5. I am tryign to maintain that expanded subnode plus redirect as
tree.aspx?id=5 (based on which the grid will be filtered. please note the treeview is in left.ascx and grid is in tree.aspx.
please help
thanks in advance
-- modified at 19:45 Wednesday 14th November, 2007
|
|
|
|
|
You have the treeview in a user control that is placed on the same page as the grid? Is this correct?
If so, why pass the id via query string? Handle the selectionchanged event on the page.
only two letters away from being an asset
|
|
|
|
|
nope. treeview is in user control and grid is in a webform. how can i pass value from user control(ascx) to webform(aspx)
|
|
|
|
|
Mark Nischalke wrote: You have the treeview in a user control that is placed on the same page as the grid?
uglyeyes wrote: treeview is in user control and grid is in a webform
A user control is not a separate webpage, it must be placed on a webpage.
It seems you have a bit learn about the technology involved before attempting this.
only two letters away from being an asset
|
|
|
|
|
hi I did grid handling on tree node selection change now I am having problem in data sorting. I am using griview control below are my codes
Protected Sub dgAssets_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs)
Response.Write(dgAssets.DataSource.GetType().ToString)
Dim dataTable As DataTable = TryCast(dgAssets.DataSource, DataTable)
If dataTable IsNot Nothing Then
Dim dataView As New DataView(dataTable)
dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection)
dgAssets.DataSource = dataView
dgAssets.DataBind()
End If
End Sub
|
|
|
|
|
here are all the codes.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
PopulateRootLevel()
End If
dgAssets.DataBind()
End Sub
Private Sub PopulateRootLevel()
Dim myDal As New clsDAL
Dim dt As DataTable
Try
dt = myDal.getRootLocation
PopulateNodes(dt, TreeView1.Nodes)
TreeView1.CollapseAll()
' get the saved state of all nodes.
Dim treeViewState As New TreeViewState()
treeViewState.SaveTreeView(TreeView1, Me.GetType.ToString())
Catch ee As Exception
Throw ee
myDal.UpdateErrorLog(ee.Message, ee.TargetSite.Name.ToString())
End Try
End Sub
Private Sub PopulateNodes(ByVal dt As DataTable, ByVal nodes As TreeNodeCollection)
For Each dr As DataRow In dt.Rows
Dim tn As New TreeNode()
tn.Text = dr("locationname").ToString()
tn.Value = dr("locationid").ToString()
nodes.Add(tn)
'If node has child nodes, then enable on-demand populating
tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0)
Next
End Sub
Private Sub PopulateSubLevel(ByVal parentid As String, ByVal parentNode As TreeNode)
Dim dt As DataTable
Dim myDal As New clsDAL
Try
dt = myDal.getChildLocation(parentid)
Catch ee As Exception
Throw ee
myDal.UpdateErrorLog(ee.Message, ee.TargetSite.Name.ToString())
End Try
PopulateNodes(dt, parentNode.ChildNodes)
End Sub
Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView1.TreeNodePopulate
PopulateSubLevel(CStr(e.Node.Value), e.Node)
End Sub
Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TreeView1.SelectedNodeChanged
'If TreeView1.SelectedNode.Value <> String.Empty Then
' Response.Redirect(TreeView1.SelectedNode.Value)
'End If
'Session("loc") = TreeView1.SelectedNode.Value
' getLocationId = TreeView1.SelectedNode.Value
locid.Text = TreeView1.SelectedNode.Value
bcId.Text = 0
binddata()
End Sub
Public Sub binddata()
Dim myDAL As New clsDAL
Dim LocationId As Integer
Dim BuildingComponentId As Integer = bcId.Text
If locid.Text <> Nothing Then
LocationId = locid.Text
Else
LocationId = 0
End If
Try
Dim dt As DataTable = myDAL.getAssetsByProperty(LocationId, BuildingComponentId)
dgAssets.DataSource = dt
dgAssets.DataBind()
Catch ee As Exception
Throw ee
myDAL.UpdateErrorLog(ee.Message, ee.TargetSite.Name.ToString())
End Try
End Sub
Protected Sub TreeView1_Unload(ByVal sender As Object, ByVal e As EventArgs) Handles TreeView1.Unload
' save the state of all nodes.
Dim tvs As New TreeViewState
tvs.SaveTreeView(TreeView1, Me.GetType().ToString())
End Sub
Function ConvertSortDirectionToSql(ByVal sortDirection As SortDirection) As String
Dim newSortDirection As String = Nothing
Select Case SortDirection
Case sortDirection.Ascending
newSortDirection = "ASC"
Exit Select
Case sortDirection.Descending
newSortDirection = "DESC"
Exit Select
End Select
Return newSortDirection
End Function
'Protected Sub dgAssets_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs)
' ' Response.Write(dgAssets.DataSource.GetType().ToString)
' Dim dataTable As DataTable = TryCast(dgAssets.DataSource, DataTable)
' If dataTable IsNot Nothing Then
' Dim dataView As New DataView(dataTable)
' dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection)
' dgAssets.DataSource = dataView
' dgAssets.DataBind()
' End If
'End Sub
'Protected Sub dgAssets_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
' binddata()
' dgAssets.PageIndex = e.NewPageIndex
' dgAssets.DataBind()
'End Sub
'CUSTOM
Private Property GridViewSortDirection() As String
Get
Return IIf(TryCast(ViewState("SortDirection"), String) Is Nothing, "ASC", TryCast(ViewState("SortDirection"), String))
End Get
Set(ByVal value As String)
ViewState("SortDirection") = value
End Set
End Property
Private Property GridViewSortExpression() As String
Get
Return IIf(TryCast(ViewState("SortExpression"), String) Is Nothing, String.Empty, TryCast(ViewState("SortExpression"), String))
End Get
Set(ByVal value As String)
ViewState("SortExpression") = value
End Set
End Property
Private Function GetSortDirection() As String
Select Case GridViewSortDirection
Case "ASC"
GridViewSortDirection = "DESC"
Exit Select
Case "DESC"
GridViewSortDirection = "ASC"
Exit Select
End Select
Return GridViewSortDirection
End Function
Protected Function SortDataTable(ByVal dataTable As DataTable, ByVal isPageIndexChanging As Boolean) As DataView
If dataTable IsNot Nothing Then
Dim dataView As New DataView(dataTable)
If GridViewSortExpression <> String.Empty Then
If isPageIndexChanging Then
dataView.Sort = String.Format("{0} {1}", GridViewSortExpression, GridViewSortDirection)
Else
dataView.Sort = String.Format("{0} {1}", GridViewSortExpression, GetSortDirection())
End If
End If
Return dataView
Else
Return New DataView()
End If
End Function
Protected Sub dgAssets_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
dgAssets.DataSource = SortDataTable(TryCast(dgAssets.DataSource, DataTable), True)
dgAssets.PageIndex = e.NewPageIndex
dgAssets.DataBind()
End Sub
Protected Sub dgAssets_Sorting(ByVal sender As Object, ByVal e As GridViewSortEventArgs)
GridViewSortExpression = e.SortExpression
Dim pageIndex As Integer = dgAssets.PageIndex
dgAssets.DataSource = SortDataTable(TryCast(dgAssets.DataSource, DataTable), False)
dgAssets.DataBind()
dgAssets.PageIndex = pageIndex
End Sub
End Class
|
|
|
|
|
Hello
I'm using parameters and values (return from function) in url like below, But it doesn't work.
Parameters are : imagepath (return from function), width, height
ImageUrl='MakeThumbnail.aspx?file=<%# getImagePath(Convert.ToString(DataBinder.Eval(Container, "DataItem.date")), "news") %>&width=<%# DataBinder.EvalContainer, "DataItem.imagewidth")%>&height=100'
Please help
|
|
|
|
|
Please don't double post.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Use the Server.UrlEncode method to encode the values properly for being put in an url.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
freshonlineMax wrote: But it doesn't work.
Why doesn't it work? You should provide basic background information about your problem if you want help. Just saying that something doesn't work isn't good enough.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I have an asp.net web page (viewxml.aspx) which accessess a sql server 2005 database record. I have a field called xmlfile which I am converting back to the xml datatype from varbinary(max) successfully. Trouble is it's hard to read. Now I need to display the field's contents as an xml file so that it can be used easily for troubleshooting. (I need display the xml formatting that is displayed automatically with the .xml file type.) I need to code it within my viewxml.aspx.vb file. I plan to use a button click event to trigger the output. Any help would be welcomed!
|
|
|
|
|
Put the XML in an XMLDocument and set the property that makes the output formatted ( forget what it is ). Then I think there's a server control to display XML. If there isn't, use a literal and HTML encode the XML string first.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
That was very non-specific and not helpful at all. 1)I do not know how to do the first thing (that was my question - how to output to a xml file and 2)there is no xml server control that I know of and 3)I don't know how to do the third thing.
|
|
|
|
|
hi friends,
I want to give the details for custom control in asp.net 2.0.
example :
Am using repeater control and link button,and then stored in 100 records(address),and paging and sorting process is doing there.
Note ;
I want coding for custom control in depending upon the example in asp.net 2.0 with c#.
with regards,
Thirumurugan.D
|
|
|
|
|
Murugan.nett wrote: I want coding
I want, doesn't get. Didn't your mother teach you this?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
i don't understand your answer.give me the way for custom control using repeater and link button.
|
|
|
|
|
Murugan.nett wrote: i don't understand your answer.
I was being sarcastic. It isn't polite to demand code, especially when it appears you have made no attempt to solve the problem yourself.
Murugan.nett wrote: give me the way for custom control using repeater and link button.
How much progress have you made through your own efforts? The obvious thing to do is to add the controls you want to repeat to the Item Template for your Repeater control. There are plenty of examples of how to use the Repeater control on the web - search for them.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I receive the following error when I try to open a .aspx file that I have created in Visual Studio 2005:
XML Parsing Error: not well-formed
Location: file:///G:/Kristian/ASP/WebSite2/Default.aspx
Line Number 1, Column 2:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
-^
Why is that? I can open sites on the internet that are .aspx!!!
I have tried to unistall .NET framework 2.0 and then installed IIS 6.0. I have then once again installed .NET framework 2.0. I have also run aspnet_regiis.exe.
Nothing helps. Any ideas of how to solve this???
Thanks!
/K
|
|
|
|
|
Is the project in ur wwwroot folder? If so, go to manage my computer and internet infomation severes, web sites. Find your website's folder and right click on it. You will need to from the properties page make it a virtual direction. Then you can go to http://localhost/ProjectFolder/Page.aspx.
|
|
|
|
|
I am working on a project where we are keeping track of tasks for other Software Projects. The program will automatically calculate estimated hours based upon what's being added, changed or whatnot. Is it possible if someone does not do that and enters what hours they think it will take based off of experience to have the hours in those rows show up in a red font or something to make it stand out?
|
|
|
|
|
I don't really understand the question. But if you just want to change the font color or background color then in RowDataBound function check your criteria and change the cssclass property of the row or just the fontcolor or backcolor.
-----
|
|
|
|
|
Thanks for the info. I will give it a shot.
|
|
|
|
|
Hi,
I have a web application that inserts data, and I am looking at capturing the created and updated date. Is there a way of determining/capturing a date and time from a specific country? What I mean is if I go to the details page of a product then I must be able to see the product was inserted with a European time, etc. etc. etc.
Please can someone advise me what to do?
Regards
Brendan
|
|
|
|
|
The JavaScript Date class has a getTimezoneOffset[^] method. When a user inserts a product, you could set the value of a server-side hidden field to the value returned from this method for the date/time the user has entered before the postback occurs. On the server-side, you should then be able to work out from this value which timezone the user is based in.
Hope this helps.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|