visionXpert
Top achievements
Rank 1
visionXpert
asked on 21 Jun 2012, 11:17 PM
I'm having a bad brain fart day... so i need a bit of help.
I have a RadTreeView looks like this
Root RadListView Goes Here
--Group1
+-- 1a
+-- 1b
+-- 1c
--Group2
+-- 2a
+-- 2b
+-- 2c
beside the above treeview, i have a RadListView in which i want to display a list of users based on what is passed by clicking anything in the treeview (ie: 1a, 1b, 1c, 2a, 2b, 2c)
I want to bind RadListView on RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e) event
whats the best way of doing this?
I have a RadTreeView looks like this
Root RadListView Goes Here
--Group1
+-- 1a
+-- 1b
+-- 1c
--Group2
+-- 2a
+-- 2b
+-- 2c
beside the above treeview, i have a RadListView in which i want to display a list of users based on what is passed by clicking anything in the treeview (ie: 1a, 1b, 1c, 2a, 2b, 2c)
I want to bind RadListView on RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e) event
whats the best way of doing this?
5 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 22 Jun 2012, 06:50 AM
Hi,
Here is the sample code which I tried based on your scenario.
ASPX:
C#:
Thanks,
Princy.
Here is the sample code which I tried based on your scenario.
ASPX:
<
telerik:RadTreeView
ID
=
"RadTreeView1"
runat
=
"server"
onnodeclick
=
"RadTreeView1_NodeClick"
>
<
Nodes
>
<
telerik:RadTreeNode
Text
=
"Node1"
Value
=
"Name1"
>
</
telerik:RadTreeNode
>
<
telerik:RadTreeNode
Text
=
"Node2"
Value
=
"Name2"
>
</
telerik:RadTreeNode
>
</
Nodes
>
</
telerik:RadTreeView
>
<
telerik:RadListView
ID
=
"RadListView1"
runat
=
"server"
>
<
ItemTemplate
>
<
span
>
<
label
> <%#Eval("FirstName") %> </
label
> <
label
> <%#Eval("LastName")%> </
label
>
</
span
>
</
ItemTemplate
>
</
telerik:RadListView
>
C#:
protected
void
RadTreeView1_NodeClick(
object
sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
{
SqlDataAdapter adapter =
new
SqlDataAdapter(
"SELECT FirstName,LastName FROM Employees WHERE FirstName='"
+ e.Node.Value +
"' "
, con);
DataTable dt =
new
DataTable();
adapter.Fill(dt);
RadListView1.DataSource = dt;
}
Thanks,
Princy.
0
visionXpert
Top achievements
Rank 1
answered on 22 Jun 2012, 07:29 PM
one thing, instead of having the ListView be databound, can you provide me with an example of how to add items to the list in a loop?
I'm hoping to do something like
while (rdr.Read())
{
ListView Add item ("<a href=\""+some url+"?SomethingToPass="+rdr["SomeValue"]+"\"">"+rdr["userName"]+"</a>");
}
As you can see i want my ListItem to be a link (not a simple label)
Please help as i'm somehow not my normal resourceful self
Thanks
I'm hoping to do something like
while (rdr.Read())
{
ListView Add item ("<a href=\""+some url+"?SomethingToPass="+rdr["SomeValue"]+"\"">"+rdr["userName"]+"</a>");
}
As you can see i want my ListItem to be a link (not a simple label)
Please help as i'm somehow not my normal resourceful self
Thanks
0
visionXpert
Top achievements
Rank 1
answered on 25 Jun 2012, 09:54 PM
tried this approach and there still isn't a refresh of the ListView on TreeNodeClick....
Debugger stops and shows there is actually values being placed in the label control, but it does not show the values after it runs through all the code, any ideas?
thanks
Debugger stops and shows there is actually values being placed in the label control, but it does not show the values after it runs through all the code, any ideas?
thanks
0
visionXpert
Top achievements
Rank 1
answered on 26 Jun 2012, 08:03 PM
This just isn't working...
Here is what i have
Here is what i have
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
EnableTheming
=
"True"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
>
</
asp:ScriptReference
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
>
</
asp:ScriptReference
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
>
</
asp:ScriptReference
>
</
Scripts
>
</
telerik:RadScriptManager
>
<
table
width
=
"100%"
border
=
"2"
>
<
tr
><
td
>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
width
=
"226px"
>
<
telerik:RadTreeView
ID
=
"RadTreeView1"
Runat
=
"server"
Width
=
"209px"
Skin
=
"Outlook"
onnodeclick
=
"RadTreeView1_NodeClick"
>
</
telerik:RadTreeView
>
</
telerik:RadAjaxPanel
>
</
td
><
td
>
<
br
/>
<
br
/>
<
telerik:RadListView
ID
=
"RadListView1"
runat
=
"server"
>
<
ItemTemplate
>
<
span
>
<
label
> <%#Eval("ReportParmName") %> </
label
> <
label
> <%#Eval("ReportParmValue")%> </
label
>
</
span
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
td
></
tr
>
</
table
>
</
form
>
</
body
>
and codebehind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * From Reports", ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString);
DataSet links = new DataSet();
adapter.Fill(links);
RadTreeView1.DataTextField = "Description";
RadTreeView1.DataFieldID = "id";
RadTreeView1.DataFieldParentID = "ParentID";
RadTreeView1.DataValueField = "id";
RadTreeView1.DataSource = links;
RadTreeView1.DataBind();
RadTreeView1.ExpandAllNodes();
}
}
protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e)
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * From ReportParameters where ReportID=" + e.Node.Value + "", ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString);
DataSet links = new DataSet();
adapter.Fill(links);
RadListView1.DataSource = links.Tables[0];
}
and while my RadTreeView1_NodeClick() fires and it seems to be filling the table with result from the query, nothing is showing..
Please HELP!
0
visionXpert
Top achievements
Rank 1
answered on 26 Jun 2012, 08:21 PM
so after banging my head on the wall....
it looks like my RadListView was outside of my RadAjaxPanel...
placing the RadAjaxPanel below the closing tag of my RadListView made this all work.
it looks like my RadListView was outside of my RadAjaxPanel...
placing the RadAjaxPanel below the closing tag of my RadListView made this all work.