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
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.
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>
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.