This is a migrated thread and some comments may be shown as answers.

[Solved] Checked nodes are null on form post

0 Answers 101 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
walid
Top achievements
Rank 1
walid asked on 25 May 2010, 11:21 AM
Hi,
I was following your exemple about how to get checked nodes on form post, but i'am getting the list of chekced nodes on my controller action null !!
Here a sample of my page code :

.....
<%

List<TreeViewItemModel> checkedNodes = ViewData["checkedNodes"] as List<TreeViewItemModel>;%>

 

<%

= Html.Telerik().TreeView()

 

.Name(

"TreeView")

 

.ShowCheckBox(

true)

 

.ExpandAll(

true)

 

.BindTo(ViewData[

Keys.UserAccesRightList] as IEnumerable<MvcAdmin.Models.TreeNode>, mappings =>

 

{

mappings.For<MvcAdmin.Models.

TreeNode>(binding => binding

 

.ItemDataBound((item, node) =>

{

item.Text = node.Name;

item.Value = node.NodeId.ToString();

 

 

if (checkedNodes != null) {

 

item.Checked = checkedNodes.Where(e => e.Value.Equals(node.NodeId.ToString())).FirstOrDefault() !=

null;

 

}

})

.Children(e => e.Children));

 

mappings.For<MvcAdmin.Models.

TreeNode>(binding => binding

 

.ItemDataBound((item, node) =>

{

item.Text = node.Name;

item.Value = node.NodeId.ToString();

 

if (checkedNodes != null)

 

{

item.Checked = checkedNodes.Where(e => e.Value.Equals(node.NodeId.ToString())).FirstOrDefault() !=

null;

 

}

})

);

})

 

%>
....

and here a sample of my controller action code :

 

[

AcceptVerbs(HttpVerbs.Post)]

 

 

public ActionResult Create(List<TreeViewItemModel> checkedNodes, UserInput userInput)

Any ideas why i'am getting selected checkboxes null?

Thanks

 

Tags
TreeView
Asked by
walid
Top achievements
Rank 1
Share this question
or