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

[Solved] Grid Editing - DropdownList

2 Answers 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bob
Top achievements
Rank 1
Bob asked on 28 Feb 2011, 10:17 PM
I am trying to provide an editable grid. When inserting a new item or editing an item, I want the user to select one of the string items in the grid from a dropdownlist. Is this possible? Can you show me how to do it?

Thanks,

Bob

2 Answers, 1 is accepted

Sort by
0
Bob
Top achievements
Rank 1
answered on 01 Mar 2011, 06:27 PM
OK, I have created an editor template for my dropdownlist, and it works.

Now, my problem is that the field that has the dropdown box also needs a textbox to be concatenated with the contents of the dropdown box. If I add a textbox to the editor template for the dropdown box, it displays correctly, but I don't seem to be able to get its value:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<string>" %>
<%= Html.DropDownList("", new SelectList(new [] {"HB", "SB", "WAC", "OTHER"}, Model)) %>
<%: Html.TextBox("bwacnum") %>

Does anyone have any ideas about how I might resolve this?

Bob
0
Bob
Top achievements
Rank 1
answered on 02 Mar 2011, 07:04 PM
I resolved this problem by splitting the field into 2 fields in the database - one for the dropdown and one for the textbox.

Bob
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Bob
Top achievements
Rank 1
Share this question
or