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

Retrieve RadGrid control dropdownlist selected values

4 Answers 123 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
nav100
Top achievements
Rank 1
nav100 asked on 24 Sep 2013, 08:45 PM
I have RadGrid with DropDownlist. I am trying to find the value of each control by loop through using Javascript.  I am getting the findcontrol as 'null'. I have attached OnClientRatingSelectedIndexChanged in code behind for the dropdownlist 'Drop1'. What could be wrong? I appreciate any suggestions.

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AlternatingItemStyle-HorizontalAlign="Left"
                               OnNeedDataSource="RadGrid1_NeedDataSource">
                                <MasterTableView DataKeyNames="level_id" PageSize="10">
                                    <Columns>
 <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Test"
                                            Visible="true">
                                            <ItemTemplate>
                                                <asp:Panel ID="Panel1" runat="server">
                                                    <asp:DropDownList ID="Drop1" runat="server"                                                                                                                                        AutoPostBack="true">
                                                    </asp:DropDownList>
                                                </asp:Panel>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                  </Columns>
</MasterTableView>
</telerik:RadGrid>

Javascript

function OnClientRatingSelectedIndexChanged(arg) {

        var grid = $find("<%=RadGrid1.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        var Rows = MasterTable.get_dataItems();
        for (var i = 0; i < Rows.length; i++) {
            var row = Rows[i];
            var drop1 = row.findControl("Drop1");  
            var val1 = drop1.selectedValue;
        }   

4 Answers, 1 is accepted

Sort by
0
nav100
Top achievements
Rank 1
answered on 25 Sep 2013, 08:58 PM
Telerik Experts, Could you please let me know how to retrieve the remaining Dropdownlist values when I select any one of Dropdownlist from RadGrid? I am stuck with this issue. Currently I have 5 rows in RadGrid. I have attached 
OnClientRatingSelectedIndexChanged for this DropdownList. I would like to compare the other DropdownList 
selected values when I select any one. Please let me know.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Sep 2013, 01:00 PM
Hello,

Please try with the below code snippet.

function test() {
 
                var grid = $find("<%= RadGrid1.ClientID %>");
 
                var MasterTable = grid.get_masterTableView();
                var Rows = MasterTable.get_dataItems();
                for (var i = 0; i < Rows.length; i++) {
                    var row = Rows[i];
                    var val1 = $(row.get_element()).find("div[id*='Panel1']").find("select[id*='Drop1']").val();
                    //OR
                    var val1 = $(row.get_element()).find("select[id*='Drop1']").val();;
                }
 
            }

Please check the below link for more information.

Access RadGrid Row and Column on Client Side :- (Get Template Column Control)

Please post your grid related question in below forum so you will get answer quickly.
http://www.telerik.com/community/forums/aspnet-ajax/grid.aspx

Thanks,
Jayesh Goyani
0
nav100
Top achievements
Rank 1
answered on 26 Sep 2013, 01:56 PM
Jayesh,

Thank you for the reply. I am getting       'Object doesn't support this property or method' error message on the following lines. Could you please suggest?

$(row.get_element()).find("div[id*='pnlElmRating']").find("select[id*='element_rating']").val()

$(row.get_element()).find("select[id*='element_rating']").val()


0
Eyup
Telerik team
answered on 27 Sep 2013, 02:09 PM
Hi Nara,

I have prepared a sample RadGrid web site to demonstrate how you can achieve the requested functionality. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Ajax
Asked by
nav100
Top achievements
Rank 1
Answers by
nav100
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Eyup
Telerik team
Share this question
or