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

Dropdown column edit value

2 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 14 Nov 2008, 06:32 PM
Hello,

I'm currently attempting to retrieve the value of a selection from a dropdown in the edit pop-up. I have been able to retrieve the values entered in a textbox and checkbox as follows:

string ProjectName = (editedItem["ProjectName"].Controls[0] as TextBox).Text;
bool IsActive = (editedItem["IsActive"].Controls[0] as CheckBox).Checked;

When I try to do so with similarly with my dropdown (shown below) I'm getting an error saying the value is null.

(editedItem["ddlContactName"].Controls[0] as DropDownList).SelectedItem.Value;

Is a different approach needed to retrieve values from dropdown cloumns?
Thanks in advance.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Nov 2008, 04:30 AM
Hi Matt,

I hope you are using a GridDropDownColumn. If so check whether you have set the correct column UniqueName. Here is the code I tried on my end.

ASPX:
 <telerik:GridDropDownColumn UniqueName="ddlContactName"  headerText="ddlContactName" ></telerik:GridDropDownColumn> 
   

CS:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode)) 
        { 
            GridEditableItem edititem = (GridEditableItem)e.Item; 
            DropDownList ddl = (DropDownList)edititem["ddlContactName"].Controls[0]; 
            string selectedVal = ddl.SelectedValue; 
        } 
    } 


If this does not help try sending your aspx.

Thanks
Shinu.
0
Matt
Top achievements
Rank 1
answered on 17 Nov 2008, 04:27 PM
That worked for me. Thank you for your help!
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Matt
Top achievements
Rank 1
Share this question
or