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

Disabling GridDropDownColumn items

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
VS
Top achievements
Rank 1
VS asked on 29 Aug 2008, 07:38 AM

Hi,

I am using GridDropDownColumn inside RadGrid.

1) How can i populate the dropdowncolumn with data during editmode and during insertmode?
2) After populating with data, how can i make certain items in the dropdown as disabled and certain as enabled?

Regards

Sujith

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Aug 2008, 09:38 AM
Hello Sujith,

1.You can populate a GridDropDownColumn during Edit/Insert Mode as shown in the code below.
aspx:
 <telerik:GridDropDownColumn UniqueName="ComboBox" DropDownControlType="RadComboBox" >         
 </telerik:GridDropDownColumn> 

cs:
 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
       if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem item = (GridEditableItem)e.Item; 
            GridEditManager editMan = item.EditManager; 
            GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("ComboBox")); 
            
            string ConnectionString1 = "Data Source=INC135; Initial Catalog=MyDataBase;User ID=sa; Password=softinc"
            SqlConnection conn1 = new SqlConnection(ConnectionString1); 
            SqlCommand cmdCustomers1 = new SqlCommand("SELECT Age FROM Reservation", conn1); 
            cmdCustomers1.CommandType = CommandType.Text; 
            conn1.Open(); 
            SqlDataReader reader1 = cmdCustomers1.ExecuteReader(); 
            editor.DataSource = reader1
            editor.DataTextField = "Age"
            editor.DataBind(); 
            conn1.Close();             
        } 
    } 


2.Also if you want to disable certain items  in the dropdown you can try the following approach.

CS:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditableItem item = (GridEditableItem)e.Item; 
            RadComboBox combo = (RadComboBox)item["columnUniqueName"].Controls[0]; 
            combo.Items[3].Enabled = false
        } 
   } 

Princy.
Tags
Grid
Asked by
VS
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or