Dropdown column edit value

3 posts, 0 answers
  1. Matt
    Matt avatar
    10 posts
    Member since:
    Nov 2008

    Posted 14 Nov 2008 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Nov 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Matt
    Matt avatar
    10 posts
    Member since:
    Nov 2008

    Posted 17 Nov 2008 Link to this post

    That worked for me. Thank you for your help!
Back to Top