This is a migrated thread and some comments may be shown as answers.
How to get Client Edit Template DropDownList's Selected Value at controller.
1 Answer 82 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Prathamesh
Top achievements
Rank 1
Prathamesh asked on 22 Apr 2011, 02:14 PM
In my project there is scenario like I have a TabStrip on one aspx page, for each tab of TabStrip I load User Control (ascx) which has a Telerik Grid on it to which data bound by Ajax technique. For grid I used PopUp Edit mode. I have used Client Edit Template for one grid which shows a DropDownList to which IndustryID and Industry pair is bound.  My problem is that when I click on Add Record or edit record Data get selected perfectly (in case of edit) to the DropDownList on popup. but when I click on Save or Update I am unable to get the selected value at Controller. I am listing code snippets below...     

Model :(EditableShow.cs)
[KnownType(typeof(EditableShow))]
public class EditableShow
{
        [ScaffoldColumn(false)]
        public int ShowID{get; set; }

        [Required(ErrorMessage = "*")]
        [DisplayName("Show")]
        public string Show{get; set;}

        [UIHint("ShowIndustry"), Required(ErrorMessage = "*")]
        public int IndustryID{get; set;}

        public string Industry{get; set;}  
}     


Grid on ascx :(ShowGrid.ascx)
<%= Html.Telerik().Grid<MARS_MVC.Models.EditableShow>()
        .Name("GridShow")
        .DataKeys(keys =>
        {
            keys.Add(s => s.ShowID);
        })
            .ToolBar(commands =>
            {
                commands.Insert().ButtonType(GridButtonType.ImageAndText).ImageHtmlAttributes(new { style = "margin-left:0" });
            })
        .Columns(columns =>
        {
            columns.Bound(s => s.Show).Width(100).Title("Show");
            columns.Bound(s => s.Industry).Width(100).Title("Industry");
            columns.Bound(s => s.IndustryID).Hidden();

            columns.Command(commands =>
            {
                commands.Edit().ButtonType(GridButtonType.Image);
            }).Width(12).Title("Edit").HtmlAttributes(new { Style="Text-Align:Center" }).HeaderHtmlAttributes(new { Style = "Text-Align:Center" });
            columns.Command(commands =>
                {
                    commands.Delete().ButtonType(GridButtonType.Image);
                }).Width(12).Title("Delete").HtmlAttributes(new { Style = "Text-Align:Center" }).HeaderHtmlAttributes(new { Style = "Text-Align:Center" });

        })
        .DataBinding(dataBinding =>
            {
                dataBinding.Ajax()
                       .Select("ShowGrid_Binding", "LookUps")
                       .Insert("Show_Insert", "LookUps")
                       .Update("Show_Update", "LookUps")
                        .Delete("Show_Delete", "LookUps");
            })
            .Editable(editing => editing.Mode(GridEditMode.PopUp))
        .Pageable()
        .Sortable()
        .Scrollable()
            .ClientEvents(events => events.OnEdit("onEdit_BindIndustryDrpList"))
%>  



Editor Template:(EditableShow.ascx)
<%= Html.HiddenFor(s => s.ShowID) %>
<table width="290px">
    <tr style="height: 20px;">
        <td>
            <fieldset style="border-color: Gray !important;">
                <legend>Show</legend>
                <table width="100%" cellspacing="5px" cellpadding="5px">
                    <tr align="left">
                        <td width="38%">
                            Show
                        </td>
                        <td width="55%">
                            <%= Html.EditorFor(s => s.Show) %>
                        </td>
                        <td width="7%">
                            <div style="color: Red;">
                                <%= Html.ValidationMessageFor(s => s.Show)%></div>
                        </td>
                    </tr>
                    <tr align="left">
                        <td width="38%">
                            Industry
                        </td>
                        <td width="55%">
                            <%= Html.EditorFor(s => s.IndustryID) %>
                        </td>
                        <td width="7%">
                            <div style="color: Red;">
                                <%= Html.ValidationMessageFor(s => s.IndustryID)%></div>
                        </td>
                    </tr>
                </table>
            </fieldset>
        </td>
    </tr>
</table>



Client Edit Template:(ShowIndustry.ascx)
<%= Html.Telerik().DropDownList()
        .Name("IndustryDrpList")
            .BindTo(new SelectList((IEnumerable)ViewData["industries"], "Id", "Name"))
%>


Any help will be appreciated.

Thanks,


1 Answer, 1 is accepted

Sort by
0
Prathamesh
Top achievements
Rank 1
answered on 26 Apr 2011, 10:03 AM
I am still stuck around the problem. I was expecting Telerik guys would revert to me.. but haven't got a single reply yet. Don't know my problem is really a tricky one or I am just making any silly mistake.
Please, if anybody come across this forum.. and have experienced the same problem then do give few minutes and suggest a workaround if you know one. It would be really helpful for me to get rid of this problem.

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