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

dependency between controls in grid

3 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Zash
Top achievements
Rank 1
Zash asked on 06 Nov 2008, 06:09 PM
 Is there  a way dependency can be established between 2 dropdown controls in the grid.

Also if i have a dropdown control outside the grid on the form, can the dropdown control in grid be dependent on dropdown control outside the grid. Can this depenedency be established?

Thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Nov 2008, 05:18 AM
Hello Ami,

You can go through the following online demo link which demonstrates how to access a dropdownlist on the SelectedIndexChanged event of another dropdownlist in the Grid, when in EditMode. Probably you can modify it for the normal mode as well.
Accessing cells and rows

Also try out the following code to access a dropdownlist in the grid on the SelectedIndexChanged event of another dropdownlist placed outside the grid.
aspx:
<asp:DropDownList ID="DropDownList1" DataSourceID="SqlDataSource2" DataTextField="Cities" AutoPostBack="true" runat="server" OnSelectedIndexChanged="DropDownList3_SelectedIndexChanged">        
</asp:DropDownList> 
 
<telerik:radgrid id="RadGrid1" DataSourceID="SqlDataSource1" AutoGenerateColumns="True" runat="server">        
     <MasterTableView> 
       <Columns>         
         <telerik:GridTemplateColumn UniqueName="Column"
           <ItemTemplate> 
            <asp:DropDownList ID="DropDownList2" runat="server"
            </asp:DropDownList>            
           </ItemTemplate> 
         </telerik:GridTemplateColumn>        
       </Columns>           
    </MasterTableView>       
</telerik:radgrid> 

cs:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
       foreach (GridDataItem dataItem in RadGrid1.Items) 
        {             
           DropDownList ddl = (DropDownList)dataItem["Column"].FindControl("DropDownList2"); 
           ddl.DataSource="";// set the datasource here 
        } 
    } 

Thanks
Princy.
0
Zash
Top achievements
Rank 1
answered on 13 Nov 2008, 08:59 PM
Sorry i ' trying to use GRID COLUMN EDITOR and was basically trying to establish dependency between dropdown control outside of grid and dropdown control as column not for each grid item during INSERT MODE not on update mode. Here is my code at design time where ddDatespan is the control outside of grid and DateID is the dropdown control as a column inside the grid.

Thanks

 

<asp:DropDownList ID="ddDateSpan"  

 

runat="server" AutoPostBack="true" OnSelectedIndexChanged="DateSpan_SelectedIndexChanged">   

 

    <asp:ListItem Text="1st 2 Week DateSpan" Value="1" Selected></asp:ListItem  

 

 

    <asp:ListItem Text="2nd 2 Week DateSpan" Value="2" ></asp:ListItem>  

 

 

</asp:DropDownList 

 

 

<telerik:RadGrid DataSourceID="SqlDataSource1" Skin="Vista" AllowAutomaticDeletes="true"   

 

 

AllowAutomaticInserts="true" AllowAutomaticUpdates="true" ID="RadGrid1" runat="server">  

 

 

<MasterTableView DataKeyNames="key" Width="100%" CommandItemDisplay="Top"   

 

 

AutoGenerateColumns="false"> 

 

 

 

 

<Columns  

 

 

     <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">   

 

 

    <ItemStyle Width="50px" />   

 

 

     </telerik:GridEditCommandColumn  

 

 

    <telerik:GridBoundColumn UniqueName="Notes" SortExpression="Notes" HeaderText="Task Notes"    

 

     DataField="Notes" ColumnEditorID= "GridTemplateColumnEditor1"> 

 

 

 

 

</telerik:GridBoundColumn  

 

 

<telerik:GridDropDownColumn DataField="Activity_id" UniqueName="ActivityTypeID" HeaderText="Activity Type"   

 

 

ListTextField="display" ListValueField="item_pk" ColumnEditorID="DropDownEditor1"   

 

 

DataSourceID="SqlDataSource_ActivityType"

 

 

 

 

</telerik:GridDropDownColumn  

 

 

<telerik:GridDropDownColumn DataField="budget_id" UniqueName="BudgetID" HeaderText="Budget"   

 

 

ListTextField="display" ListValueField="id" ColumnEditorID="DropDownEditor2"   

 

 

DataSourceID="SqlDataSource_Budget"

 

</telerik:GridDropDownColumn  

 

 

<telerik:GridDropDownColumn UniqueName="DateID" HeaderText="Activity Date" > 

 

 

   

i want list item to generate for this control upon changing index   
for ddDateSpan dropdown control



</

 

 

telerik:GridDropDownColumn> 

 

 

</Columns

 

 

 

 

</MasterTableView

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

0
Yavor
Telerik team
answered on 14 Nov 2008, 06:31 AM
Hi Ami,

Attached to this message, is a small application, which handles a functionality along the lines of the question you set forth.
I hope it helps.

Best wishes,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Zash
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Zash
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or