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

Working with Combobox Column in grid

1 Answer 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 20 Jan 2014, 12:41 PM
Hi,
I am new to telerik controls. I am working on below scenario 
I have  one Rad Grid which will have 3 columns out of which one is dropdown column. I am able to populate the combo box on page load but I want that Values in other two columns should get populated based on what value is selected in combo box column.

Please let me know how to do this.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Jan 2014, 07:00 AM
Hi rahul,

Im not clear about your requirement, i guess you want to access a dropdownlist in GridTemplateColumn and fill the other columns based on its value. Here is a sample code snippet please have a look into this, if it doesn't help, provide your code if any and elaborate on your requirement.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server">
    <MasterTableView DataKeyNames="OrderID">
        <Columns>
            <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <asp:DropDownList DataSourceID="SqlDataSource1" AutoPostBack="true" DataTextField="ShipCountry"
                        DataValueField="ShipCountry" ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                    </asp:DropDownList>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
  DropDownList drop=(DropDownList)sender;
  GridDataItem item = (GridDataItem)drop.NamingContainer;
  string value = drop.SelectedValue;
  Label lbl = (Label)item.FindControl("Label1");
  lbl.Text = "Your Text";
}

Thanks,
Princy
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or