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

[Solved] populating grid bound cloumns inside radgrid

4 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hari
Top achievements
Rank 1
Hari asked on 07 May 2013, 06:36 PM
Hiii,

I have rad grid. in side that i have a combo box. I want to populate the other columns of rad grid based on the value selected on the combo box inside the rad gird. The rad grid is bidden to an object data source.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 May 2013, 03:57 AM
Hi,

I guess you want to change the Table cell text of a RadGrid row depending upon the value selected in the RadCombobox. Please check the following code snippet.

C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
        RadComboBox combo=(RadComboBox)sender;
        GridDataItem data = (GridDataItem)combo.NamingContainer;
        if(combo.SelectedValue=="you text")
        {
            data["UniqueName"].Text = "your data";
        }
}

Thanks,
Princy.
0
Hari
Top achievements
Rank 1
answered on 08 May 2013, 05:48 AM
Hai princy, 

Thanks for the prompt response and the code is working fine. But my requirement is to populate the text box inside intem template of rad grid based on the rad box selected value.

for Eg: i have four item template column in rad grid. ItemName, PartNo, Price, Discount. Item Name and PartNO are combobox and Price and Discount are rad numeric textbox. I want to auto fill all the other three fields based on the combobox selected value and i want to get that in edit form. The values should populate inside the text box and if i want to edit it, there should be an option to edit the auto fill values in text box as well.

Expecting your prompt response at the earliest

Hari

Please find the itemtemplate sample of drid column

 <telerik:GridTemplateColumn AllowFiltering="True" AutoPostBackOnFilter="true" DataField="unitcost"
                            HeaderText="Unit Price" UniqueName="unitcosttemp">
                            <ItemTemplate>
                                <asp:Label ID="lblunitcost" runat="server" Text='<%# Eval("unitcost") %>'></asp:Label>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <span>
                                    <telerik:RadNumericTextBox ID="txtunitcost" runat="server" MaxLength="50" Text='<%# Bind("unitcost") %>'
                                        Width="150px">
                                    </telerik:RadNumericTextBox>
                                    <span style="color: Red"></span>
                                    <asp:RequiredFieldValidator ID="valunitcost" runat="server" ControlToValidate="txtunitcost"
                                        ErrorMessage="*" ForeColor="Red">
                                    </asp:RequiredFieldValidator>
                                </span>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
0
Princy
Top achievements
Rank 2
answered on 09 May 2013, 03:42 AM
Hi,

I guess the RadComboBoxes are inside the EditItemTemplate of GridTemplateColumn.  Please take a look into the following code snippet to fill the RadNumericTextBox based on the selected value of the RadComboBox.

C#:
protected void RadC_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
    RadComboBox combo=(RadComboBox)sender;
    GridEditableItem editdata = (GridEditableItem)combo.NamingContainer;
    if(combo.SelectedValue=="your value")
    {
        RadNumericTextBox txt = (RadNumericTextBox)editdata .FindControl("RadNumericTextBox1");
        txt.Text = "your text";
    }
}

Thanks,
Princy.
0
Hari
Top achievements
Rank 1
answered on 09 May 2013, 07:15 AM
Hii Princy

Thanks very much.
Its working perfectly
Tags
Grid
Asked by
Hari
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Hari
Top achievements
Rank 1
Share this question
or