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

[Solved] About Operations with MS DropDownList in EditItemTemplate of GridTemplateColumn

1 Answer 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dao
Top achievements
Rank 1
Dao asked on 21 May 2009, 10:41 AM
After clicking edit, the data in the label does not show on RadGrid.
Select SelectIndex?

 DropDownList list = item.FindControl("List1") as DropDownList;
           list.DataSource = Country_values;
           list.DataBind();

           list.SelectedIndex = ?????; <<<Here

Pls



1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 May 2009, 06:21 AM
Hi Dao,

When using dropdownlist in EditItemTemplate, you can save the selected value in a Session variable and then set that value for the label in ItemTemplate. The same Session variable can be used to select the default item in the dropdown control on subsequent editing.

In the above post I saw that you are setting the SelectedIndex instead of SelectedValue. Can you try setting selectedValue to the session variable value and see whether it is working fine?

CS:
 
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
    { 
        GridEditableItem item = e.Item as GridEditableItem; 
        // access/modify the edit item template settings here 
        DropDownList list = item.FindControl("List1"as DropDownList; 
        list.DataSource = Country_values; 
        list.DataBind(); 
        if (Session["updatedValue"] != null
        { 
            list.SelectedValue = Session["updatedValue"].ToString(); 
        } 
    } 
    . . . 
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) 
    GridEditableItem editedItem = e.Item as GridEditableItem; 
    DropDownList list = editedItem.FindControl("List1"as DropDownList; 
    Session["updatedValue"] = list.SelectedValue

Thanks,
Shinu.
Tags
Grid
Asked by
Dao
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or