Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 24, 2012 01:23 PM by suderson
Member
69 Points
49 Posts
Feb 24, 2012 05:16 AM|LINK
I've a MVC HTML Combo binded in my View
@(Html.Telerik().DropDownList().Name("ddlUserAccess").BindTo(new SelectList((IEnumerable)SessionHandler.UserRoles, "Value", "Text", UserAccess)).HtmlAttributes(new { style = "width:268px;height:20px; " }))
I've a Grid too, in the same view
When I select a row in the Grid, I'm calling a javascript method which will dispay the cell values in the text box. I want to display the cell value in my dropdown list. I'm able to set value by using the below 2 methods:
Method 1: $("#ddlUserAccess")[0].value = e.row.cells[6].innerHTML; $("#ddlUserAccess")[0].defaultValue = e.row.cells[6].innerHTML
Method 2: document.getElementById("ddlUserAccess").value = e.row.cells[6].innerHTML; document.getElementById("ddlUserAccess").defaultValue = e.row.cells[6].innerHTML;;
But I'm unable to see it in the view.
Can any one help on this ??
All-Star
135023 Points
21648 Posts
Moderator
MVP
Feb 24, 2012 07:13 AM|LINK
enable javascript errors .
286 Points
131 Posts
Feb 24, 2012 12:54 PM|LINK
try to debug with javascript console error.
Firebug in FireFox (ctrl+j)
Developer tool in Chrome (ctrl+i)
Feb 24, 2012 01:23 PM|LINK
Hi, HEre is how I did it
var reportGroupdropDownList = $("#ddlReportGroup").data("tDropDownList");
if (reportGroupdropDownList != undefined && reportGroupdropDownList.data != undefined) {
for (var i = 0; i < reportGroupdropDownList.data.length; i++) {
if (reportGroupdropDownList.data[i].Value == e.row.cells[4].innerHTML) {
reportGroupdropDownList.select(i); break;
}
suderson
Member
69 Points
49 Posts
Through Javascript, Set Value to Drop Down
Feb 24, 2012 05:16 AM|LINK
I've a MVC HTML Combo binded in my View
@(Html.Telerik().DropDownList().Name("ddlUserAccess").BindTo(new SelectList((IEnumerable)SessionHandler.UserRoles, "Value", "Text", UserAccess)).HtmlAttributes(new { style = "width:268px;height:20px; " }))
I've a Grid too, in the same view
When I select a row in the Grid, I'm calling a javascript method which will dispay the cell values in the text box. I want to display the cell value in my dropdown list. I'm able to set value by using the below 2 methods:
Method 1:
$("#ddlUserAccess")[0].value = e.row.cells[6].innerHTML;
$("#ddlUserAccess")[0].defaultValue = e.row.cells[6].innerHTML
Method 2:
document.getElementById("ddlUserAccess").value = e.row.cells[6].innerHTML;
document.getElementById("ddlUserAccess").defaultValue = e.row.cells[6].innerHTML;;
But I'm unable to see it in the view.
Can any one help on this ??
ignatandrei
All-Star
135023 Points
21648 Posts
Moderator
MVP
Re: Through Javascript, Set Value to Drop Down
Feb 24, 2012 07:13 AM|LINK
enable javascript errors .
imteyazahmad...
Member
286 Points
131 Posts
Re: Through Javascript, Set Value to Drop Down
Feb 24, 2012 12:54 PM|LINK
try to debug with javascript console error.
Firebug in FireFox (ctrl+j)
Developer tool in Chrome (ctrl+i)
suderson
Member
69 Points
49 Posts
Re: Through Javascript, Set Value to Drop Down
Feb 24, 2012 01:23 PM|LINK
Hi, HEre is how I did it
var reportGroupdropDownList = $("#ddlReportGroup").data("tDropDownList");
if (reportGroupdropDownList != undefined && reportGroupdropDownList.data != undefined) {
for (var i = 0; i < reportGroupdropDownList.data.length; i++) {
if (reportGroupdropDownList.data[i].Value == e.row.cells[4].innerHTML) {
reportGroupdropDownList.select(i); break;
}
}
}