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. Image for the cookie policy date
close icon

grid dropdown not returning value only text

The HTML generated from the dropdown in a grid is not using the value field only the text field. When the record gets saved no id value is returned.
 
Controller
List<dropdown> dataf = new List<dropdown>();
foreach (Fleet f in db.Fleets.ToList())
{
   dropdown fleet = new dropdown();
   fleet.id = f.FleetID;
   fleet.name = f.FleetName;
   dataf.Add(fleet);
}
ViewData["FleetsDropDownSource"] = dataf;
 
View
 Html.Syncfusion().Grid<FleetPlanner.Models.Asset>("AssetGrid")
      .Datasource(Model)
      .EnablePaging()
      .EnableSorting()
      .Caption("Assets")
      .Column( column => {
          column.Add(p => p.AssetID).HeaderText("ID").Visible(false);
          column.Add(p => p.AssetName).HeaderText("Asset Name");
          column.Add(p => p.Fleet.FleetName).HeaderText("Fleet Name").CellEditType(CellEditType.DropdownEdit).DropDownDataSource((System.Collections.IEnumerable)ViewData["FleetsDropDownSource"],"name","id");
      })
 
Generated HTML for DropDown
<option value="C130">C130</option>
<option value="Centurion">Centurion</option>
<option selected="selected" value="FA18">FA18</option>
 

11 Replies

BM Bala Murugan A.S Syncfusion Team March 8, 2013 04:44 AM UTC

Hi Peter,

We regret for the inconvenience caused. We are unable to reproduce your reported issue in our end. The selected value of the dropdownlist only gets saved in the database. Please refer the below screenshot.

[screenshot]

DropDownDS.zip

Could you provide a simple sample which will replicate your issue so that we could able to sort out the cause of this issue and provide you a better solution quickly?.

Please let us know if you have any concerns.

Regards,

Bala Murugan A.S



PF peter foley March 11, 2013 09:59 PM UTC

What I want i to return is the key field value not the text field. In your example of countries these are the same! So for example if the drop down list is based on a country code & name structure (1, "USA", 2, "AUS", etc) I want it to show USA, AUS etc and return the selected code value 1 or 2 etc


MK Maithiliy K Syncfusion Team March 14, 2013 10:04 AM UTC

Hi Peter,

Thanks for using Syncfusion product.

Based on your requirement, we have created a simple sample in both Server and JSON mode by binding the “Text” and “Value” field for the dropdown edit column.

We are afraid that we are unable to reproduce the issue reported by you. Can you please attach the sample in this forum or modify our sample , so that we could sort out the cause of the issue and provide you a solution.

Sample Link : http://www.syncfusion.com/downloads/Support/DirectTrac/105400/DropDown195451240.zip

 

Please let us know if you would require any further assistance.

 

Regards,

Maithiliy K



PF peter foley March 15, 2013 12:04 AM UTC

I have looked at your example (thanks) but my situation is a bit more complex.

The Asset class contains 2 other classes. It is these other classes I wish to be used as the datasource for the dropdowns (see Assett\Index controller and Asset.cshtml view) to set Fleet and Asset Type.

I want to show FleetName for Fleet when reading the grid and the dropdown when editing.Maybe I need some form of Template?


FleetPlanner_596e041a.zip


BM Bala Murugan A.S Syncfusion Team April 1, 2013 06:58 AM UTC

Hi Peter,

Sorry for the inconvenience caused.

Currently we are working on this with high priority and we will update you in one business day(April 2,2013).

Please let us know if you have any concerns.

Regards,
Bala Murugan A.S


PJ paul jilek April 16, 2013 04:12 AM UTC

Hi Bala
 
I have the same requirement as Peter.  Could you please inform me of the outcome?
 
Cheers
 
Paul


BM Bala Murugan A.S Syncfusion Team April 25, 2013 04:12 AM UTC

Hi Paul,

Thanks for your update.

We suggest you to refer the Direct Trac incident 107426 for your query.

Please let us know if you have any other concerns.

Regards,
Bala Murugan A.S


MU Murugan May 8, 2013 11:43 PM UTC

I am also facing the similar kind of problem.

cols.Add(c => c.TitleName).HeaderText("Title").Width(30).CellEditType(CellEditType.DropdownEdit).DropDownDataSource((System.Collections.IEnumerable)ViewData["DropDownSource"], "Name""Id");

I have to display the "Mr / Mrs / Dr" and so on. When I select the text from the dropdownlist and move to the next row - the value has been display in the grid rather than the selected text.

Please find the attachment of the screen shot and let me know the solution. 



GridDropdownlist_6876da3b.rar


BM Bala Murugan A.S Syncfusion Team May 14, 2013 03:50 AM UTC

Hi Murugan,

Thanks for your update.

Currently we are analyzing on your query with high priority and we will update you on May 17,2013.

Please let us know if you have any concerns.

Regards,
Bala Murugan A.S


SL Stephanie L. Hayden April 3, 2014 12:02 AM UTC

Has this issue been resolved? If so, is there a sample available?


PS Prabu Sarvesan Syncfusion Team April 3, 2014 07:38 AM UTC

Hi Stephanie,

 

Thanks for your interest in Syncfusion products.

 

We have logged this as a feature request in our database. We will implement this feature in any of our upcoming releases. We usually have an interval of at least three months between releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We will update you when this feature has been implemented

 

Disclaimer: The date for the feature implementation is tentative and not a commitment on our parts.

 

Please let us know if you need any further assistance.

 

Regards,

Prabhu Sarvesan


Loader.
Live Chat Icon For mobile
Up arrow icon