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

Rad Grid

1 Answer 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
al
Top achievements
Rank 1
al asked on 18 Dec 2008, 05:59 AM

Hi! can anyone help me with this.

i am using a radgrid and i set its edit mode into editforms. when i click the edit button, the items are edited, which is fine. the items are 3 GridNumericColumn, 1 GridTemplateColumn and 1 GridBoundColumn. in the template column is a asp dropdownlist. all i want to happen is when i click the dropdownlist and select specific item on it, it will disable the other fields. then if i select another, it will enable the other 2 numeric boxes.

some codes below.

protected

 

void dgNumeric_ItemCreated(object sender, GridItemEventArgs e)

 

{

 

if (e.Item is GridEditableItem && e.Item.IsInEditMode)

 

{

 

if (((string)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Title"]).ToUpper() == "Between".ToUpper() ||

 

((

string)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Title"]).ToUpper() == "Not Between".ToUpper())

 

{

(e.Item

as GridEditableItem)["PropertyName"].Enabled = false;

 

}

 

else

 

 

 

 

 

{

(e.Item

as GridEditableItem)["RangeFrom"].Enabled = false;

 

(e.Item

as GridEditableItem)["RangeTo"].Enabled = false;

 

}

 

 

GridEditableItem editedItem = e.Item as GridEditableItem;

 

 

DropDownList list = editedItem.FindControl("ddlValue") as DropDownList;

 

list.Text = ((

string)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Title"]);

 

}

}

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Dec 2008, 08:27 AM
Hello,

I hope you are trying to disable controls in the EditForm depending on the item selected in the dropdownlist. For the same, you would have to access the controls in the SelectedIndexChanged event of the dropdownlist and then disable the controls as shown below:

cs:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editedItem = (GridEditableItem)e.Item; 
            DropDownList dropdown = (DropDownList)editedItem["TemplateColumnUniqueName"].Controls[0]; 
            dropdown.AutoPostBack = true
            dropdown.SelectedIndexChanged += new EventHandler(dropdown_SelectedIndexChanged); 
        }   
        
    } 
 
 
   void dropdown_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        DropDownList ddl = (DropDownList)sender; 
        if(ddl1.Text=="Anna") 
        { 
          GridEditableItem editItem = (GridEditableItem)ddl.NamingContainer; 
          ((TextBox)editItem["BoundColumnUniqueName"].Controls[0]).Enabled = false
        } 
    } 

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