We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dropdown in Grid Issue

Thread ID:

Created:

Updated:

Platform:

Replies:

109971 Jul 13,2013 09:28 PM UTC Jul 16,2013 10:42 AM UTC ASP.NET MVC (Classic) 1
loading
Tags: Grid
Joseph Orjinta
Asked On July 13, 2013 09:28 PM UTC

Hello,
 
I have issues with populating Dropdown in Grid, The Dropdown comes up with
'System.Collections.Generic.Dictionary`2[System.String, System.Object]  items populated in the dropdown list.
 
This is code at the controller
 

public class AdminController : Controller

{

private IChapterRepository repositoryChapter;

private IBranchRepository repositoryBranch;

public AdminController(IChapterRepository chapterRepository, IBranchRepository branchRepository)

{

this.repositoryChapter = chapterRepository;

this.repositoryBranch = branchRepository;

}

/// <summary>

/// Used for rendering the grid initially.

/// </summary>

/// <returns>Veiw page, it displays the Grid</returns>

public ActionResult Chapters()

{

 

ViewData[

"BranchCode"] = BranchList;

var data = repositoryChapter.Chapters.ToList();

return View(data);

}

public IEnumerable<SelectListItem> BranchList

{

get

{

List<SelectListItem> type = new List<SelectListItem>();

var branches = repositoryBranch.Branches;

foreach (var branch in branches)

{

type.Add(

new SelectListItem

{

Text = branch.BranchName,

Value = branch.BranchCode

});

}

return type;

}

}

....

 

CODE AT THE CSHTML

.Datasource(Model)

.ActionMode(Syncfusion.Mvc.Grid.

ActionMode.Server)

.Caption(

"Chapters").Scrolling(s => s.Height(300))

.Column(column =>

{

column.Add(c => c.ChapterId).HeaderText(

"Chapter ID").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Left).Width(100);

column.Add(c => c.ChapterName).HeaderText(

"Chapter Name").TextAlign( Syncfusion.Mvc.Grid.TextAlignment.Left).Width(100);

column.Add(c => c.ChapterFullName).HeaderText(

"Chapter Full Name").Width(130);

column.Add(c => c.BranchCode).HeaderText(

"Branch").CellEditType(CellEditType.DropdownEdit).Width(130).DropDownDataSource((System.Collections.IEnumerable)ViewData["BranchCode"]);

column.Add(c => c.EmailAddress).HeaderText(

"Email Address").Width(110);

})

.EnablePaging()

.EnableSorting()

.AutoFormat(Syncfusion.Mvc.Shared.

Skins.Marble)

.Caption(

"Chapters")

.ToolBar(tools =>

{

tools.Add(

GridToolBarItems.AddNew)

.Add(

GridToolBarItems.Edit)

.Add(

GridToolBarItems.Delete)

.Add(

GridToolBarItems.Update)

.Add(

GridToolBarItems.Cancel);

})

.Mappers(mapper =>

{

mapper.InsertAction(

"AddChapter")

.SaveAction(

"ChapterSave")

.DeleteAction(

"DeleteChapter");

})

.Editing(edit =>

{

edit.AllowEdit(

true)

.AllowNew(

true)

.AllowDelete(

true);

edit.PrimaryKey(key => key.Add(c => c.ChapterId));

})

)

 

PLEASE CAN YOU HELP, BEING STUCK FOR 4 DAYS

 


Abdul Matin M [Syncfusion]
Replied On July 16, 2013 10:42 AM UTC

Hi Joseph,


Thanks for your interest in Syncfusion products.

 

I have created a sample based on your code snippet. Could you use that sample and reproduce the error if any. We have resolved your issue by giving the name of the dataTextField and dataValueField in DropDownDataSource method.

 

Please refer the below online documentation link:

http://help.syncfusion.com/UG/ASP.NET%20MVC/Grid/documents/databindingsupportfo.htm


For your convenience we have attached a sample and screenshot. Could you use that sample and get back to us if you have any queries.

 

Let us know if you have any concerns.

 

Regards,

Abdul Matin M

 



DropDown1_ba906b51.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;