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

Rad Grid with Dropdown Columns

7 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 05 Oct 2010, 12:26 PM
Hey there,

I am working on a form using rad controls.I need to make a grid in which first column contains a dropdown,and on its selectedItemIndexChanged I want to show the price of the selected item in the next column on a label.What's the procedure?..
Should i use GridItemTemplate?..Is there any Grid demo which shows a dropDopwn column?..

Need Some help...
Thanks
Amit.

7 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Oct 2010, 01:04 PM
Hi Amit,

One ethod to accomplish this functionality is by using GridTemplateColumn with RadComboBox in ItemTemplate section. Populate the RadComboBox and in the SelectedIndexChanged event, get the GridDataItem using NamingContainer property of combo control (sender). Now using FindControl() method, get the Label control placed in same row and set the Text property.

I hope this suggestion helps.


Thanks,
Princy.
0
Amit
Top achievements
Rank 1
answered on 06 Oct 2010, 06:50 AM
Hey,

Could i get some demo or an example for getting started?..That'll help a lot.

Thanks.
0
Accepted
Princy
Top achievements
Rank 2
answered on 06 Oct 2010, 07:19 AM
Hello Amit,

Here is the sample code to achieve the similar scenario.

ASPX:
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1"
            DataTextField="EmployeeID" DataValueField="EmployeeID" AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
        </telerik:RadComboBox>
    </ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
    </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
  {
      RadComboBox combo = (RadComboBox)o;
      GridDataItem item = (GridDataItem)combo.NamingContainer; //get GridDataItem using NamingContainer property
      Label lbl = (Label)item.FindControl("Label2");//access Label
      lbl.Text = "100"; // set Text property of Label
  }

Thanks,
Princy.
0
Raj
Top achievements
Rank 1
answered on 20 Jan 2011, 03:56 AM
Hi Princy,

I need some help. My radgrid has many columns and few of them are buttons (open, edit, close).  I was wondering if we could have all these buttons in one column showing as a drop down list. Thanks for your time.

Regards,
Raj
0
Princy
Top achievements
Rank 2
answered on 20 Jan 2011, 08:49 AM
Hello,

Option #1:
One suggestion is using RadComboBox with the items - Open, Edit and Close. Now in the SelectedIndexChanged event, get the Item selected and perform the corresponding action.

Option #2:
Another option is using RadToolBar control to show DropDown with buttons. Now in the "onbuttonclick" event get reference to item using NamingContainer as described in previos forum reply.
<telerik:RadToolBar AutoPostBack="true" ID="RadToolBar1" runat="server" Skin="Black"
     Width="100px" onbuttonclick="RadToolBar1_ButtonClick">
    <Items>
        <telerik:RadToolBarDropDown>
            <Buttons>
                <telerik:RadToolBarButton Text="open">
                </telerik:RadToolBarButton>
                <telerik:RadToolBarButton Text="edit">
                </telerik:RadToolBarButton>
            </Buttons>
        </telerik:RadToolBarDropDown>
    </Items>
</telerik:RadToolBar>
 

Thanks,
Princy.
0
Sri
Top achievements
Rank 1
answered on 06 Mar 2014, 12:13 AM
Hi there,
                I did exactly what you have mentioned, but the updating of the label text is not restricted to the particular row, the labels text on the other rows also get,updated. Any thoughts??
0
Princy
Top achievements
Rank 2
answered on 06 Mar 2014, 04:35 AM
Hi Sri,

This is not an expected behavior, the above code snippet works fine at my end. Please provide your code snippet to understand the issue.

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