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

[Solved] Changing datasource combo in Radgrid Form template?

7 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 30 Sep 2009, 07:25 PM
Hi, I'm using Form Template in my radgrid. I have several combobox that when I change, I wanted to change other combobox datasource. For instance 1st combo is course, 2nd is Level and 3rd is teacher. If i'm going to change my course combo it will change data for my level and teacher combo.

Any inputs would be a great help.. Thanks in advance..

Heres some sample code:

<EditFormSettings EditFormType="Template">  
                    <FormTemplate> 
                         
                        <table id="tblAddEdit" cellspacing="1" cellpadding="1" width="100%" border="0" runat="server" > 
                            <tr> 
                                <td > 
                                </td> 
                                <td> 
                                </td> 
                            </tr> 
                             <tr> 
                                <td> 
                                    Course:</td> 
                                <td> 
                                    <asp:DropDownList ID="cboCourse" runat="server" Width="200px" 
                                        TabIndex="1" AppendDataBoundItems="true">  
                                    </asp:DropDownList> 
                                    <asp:RequiredFieldValidator ID="Requiredfieldvalidator00" Runat="server" Display="Dynamic" ControlToValidate="cboCourse" ErrorMessage="Select Course" /> 
                                    <asp:label ID="lblCourseID" runat="server" Visible="false" Text='<%# eval("CourseID") %>'></asp:label> 
                                    </td> 
                            </tr> 
                            <tr> 
                                <td colspan="2" style="height:6px" > 
                                </td> 
                            </tr> 
                            <tr> 
                                <td> 
                                    Level:</td> 
                                <td> 
                                    <asp:DropDownList ID="cboLevel" runat="server" Width="200px" 
                                        TabIndex="1" AppendDataBoundItems="true">  
                                    </asp:DropDownList> 
                                    <asp:RequiredFieldValidator ID="Requiredfieldvalidator0" Runat="server" Display="Dynamic" ControlToValidate="cboLevel" ErrorMessage="Select Level" /> 
                                    <asp:label ID="lblLevelId" runat="server" Visible="false" Text='<%# eval("SubjectCode") %>'></asp:label> 
                                    </td> 
                            </tr> 
                            <tr> 
                                <td colspan="2" style="height:6px" > 
                                </td> 
                            </tr> 
                             <tr> 
                                <td> 
                                    Teacher:</td> 
                                <td> 
                                    <asp:DropDownList ID="cboTeacher" runat="server" Width="200px" 
                                        TabIndex="2" AppendDataBoundItems="true">  
                                    </asp:DropDownList> 
                                    <asp:RequiredFieldValidator ID="Requiredfieldvalidator1" Runat="server" Display="Dynamic" ControlToValidate="cboTeacher" ErrorMessage="Select Teacher" /> 
                                    <asp:label ID="lblTeacherID" runat="server" Visible="false" Text='<%# eval("TeacherID") %>'></asp:label> 
                                    </td> 
                            </tr> 
                            <tr> 
                                <td colspan="2" style="height:6px" > 
                                </td> 
                            </tr> 
                         ....  
                         ....   
                         ....   
  </FormTemplate> 

RJ

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Oct 2009, 05:18 AM
Hello RJ,

You can refer to the following online demo to set up a scenario as yours where in the comboboxes can interact with each other using client-side methods and request the items on demand. This should probably guide you better:
Related ComboBoxes

Thanks
Princy.
0
RJ
Top achievements
Rank 1
answered on 01 Oct 2009, 03:17 PM
Hi princy, seems like this solution is not for radgrid form template. I cannot use ItemsRequested for radcombo will only be created during Item databound. Im sure this would work with radcombo in aspx but if used inside radgrid form template, it will not.. Or most probably will require several more tweaks which for now I dont know how. Thanks
0
Parth
Top achievements
Rank 1
answered on 06 Oct 2009, 06:01 PM
Hi RJ,

I was wondering if you ended up finding a solution, as I am trying to do the same thing in my app, and havne't figured it out either.

Thanks,
Parth
0
RJ
Top achievements
Rank 1
answered on 06 Oct 2009, 07:07 PM

Hi Parth,

 

I wasn't been successful using the form template but you can use radwindow as a replacement. heres the link on how to use radwindow form for editing and inserting: http://www.telerik.com/support/kb/aspnet-ajax/grid/using-radwindow-for-editing-inserting-radgrid-records.aspx  

Since its a separate form you can now then apply the related combo sample. But then it will not be as smooth as form template coz it does some post back when opening the radwindow. Unless there's some other way on how to make it postback free which for now I don't know.

Hope this helps,
RJ 

0
Parth
Top achievements
Rank 1
answered on 06 Oct 2009, 07:33 PM
Hey Rj,

That was what I was thinking of doing, as I didn't want to use the other option of telerik:GridDropDownColumn, and making a trip to the database and binding the combo every row.  Just do it on row edit.  As it turns out the grid I am doing this for, is in a radwindow itself.  I haven't tried a radwindow in a radwindow yet, so i'll see how it goes! 

Thanks!
Parth
0
Parth
Top achievements
Rank 1
answered on 07 Oct 2009, 07:23 PM
Hey RJ,

Think I found the solution with the help of a couple other posts.  Not sure its helpful since you already got it working using a window.  However for future reference. Where ddl1 is the combo in the Form Template.

protected void ddl1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)        
        {        
            RadComboBox rcb1 = (RadComboBox)o; ;        
            RadComboBox rcb2 = new RadComboBox();        
            GridEditableItem dataItem = (GridEditableItem)rcb1.NamingContainer;        
            rcb2 = (RadComboBox)dataItem.FindControl("ddl2");        
            Bind_DDL2(rcb1, rcb2);      
}   

Thanks,
Parth
0
RJ
Top achievements
Rank 1
answered on 08 Oct 2009, 03:57 AM
Hi Parth,

Will gonna give this a try.

Thanks for the info,
RJ
Tags
Grid
Asked by
RJ
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
RJ
Top achievements
Rank 1
Parth
Top achievements
Rank 1
Share this question
or