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

RadComboBox Data binding and data source in RadGrid

2 Answers 693 Views
Grid
This is a migrated thread and some comments may be shown as answers.
bEnDi
Top achievements
Rank 2
bEnDi asked on 23 Oct 2008, 04:52 PM
Hi,

I was wondering whether is there a way where i can bind(Edit Binding) the RadComboBox to a column in a table but it's data source(choose data source) is from a different table compare to the binding table. The reason why i want to do this is:

1. I have a table in the database which contains all the items require for the combobox where a user can add/remove the combobox item and if i use "Build RadComboBox" the item is fix, when ever i want to add/remove and item the webmaster have to do it. Whereas if i use a database, the item of the combobox can be add/remove directly without the webmaster.

2. the combox box's item is filter depending on another combobox item

3. i'm  using custom command item template for add,delete,update record and etc and by binding the combox to the column in a table reduces coding such as INSERT sql command.

So, is there a way to do this? Is there any sample that i can rely on?

Thanks.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Oct 2008, 05:48 AM
Hello Lendi,

You can bind the RadComboBox to a different DataTable in EditMode by accessing it and then changing its DataSource attribute.
aspx:
<EditFormSettings EditFormType="Template"
    <FormTemplate> 
                 
       <telerik:RadComboBox ID="ComboList1" runat="server" AutoPostBack="true"
       </telerik:RadComboBox>                    
     </FormTemplate> 
  <PopUpSettings ScrollBars="None" />                     
</EditFormSettings> 

cs:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            RadComboBox combolist = (e.Item as GridEditableItem).FindControl("ComboList1") as RadComboBox; 
            combolist.DataSource = "";// Bind the combobox to the DataTable  
        } 
    } 

2. You can get a combobox to populate based on another combobox value as shown in the online demo link below. The example shows how to create a SelectedIndexChanged event handler for the first combobox and in that event handler how to access the second combobox and change its datasource, when the grid is in EditMode.
Accessing cells and rows

3. You can go through the following demo link to understand how to perform automatic operations on grid using CommandItem.
Command item

Thanks
Princy.
0
bEnDi
Top achievements
Rank 2
answered on 24 Oct 2008, 08:16 PM
Hi Princy,

Thanks for all the infomation but it still doesn't fulfill my requirement. Is there anyway that it can be done more easily?? Previously by using the default tool in Visual Web Developer i was able to use the objectdatasource where it's parameter control id is assigned to a another control(dropdownlist). I feel that it is much more simplier.

Now that i use radcombobox, the control id function is no more applicable. So is there any guide or sample which i can refer to??? The sample demo(accessing cell and rows) does not give me a good idea where i have 50 columns of radcombobox to deal with. Is there a way i can do it by using objectdatasource??
Tags
Grid
Asked by
bEnDi
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
bEnDi
Top achievements
Rank 2
Share this question
or