Can't edit contents of a GridViewLookUpColumn

3 posts, 0 answers
  1. mtaber
    mtaber avatar
    12 posts
    Member since:
    Oct 2006

    Posted 31 Dec 2009 Link to this post

    Forgive the cross-post, but I didn't realize until afterwards that GridViewLookUpColumn should be asked here instead.
    I have a GridView that has three columns. The first is read only and named RuleKeyGuid. The second is called RuleKey, and the last is called KeyValue. I'd like for the second column to be a drop-down that suggests what the user might be looking for based on a data source. Here's what I entered:

    System.Collections.IDictionaryEnumerator iterator = sortedRuleKeys.GetEnumerator();
    while (iterator.MoveNext())
        GridViewRowInfo rowInfo = radGridView_RuleKeys.Rows.AddNew();
        rowInfo.Cells[0].Value = ((RuleKey)iterator.Value).RuleKeyGuid.ToString();
        rowInfo.Cells[1].Value = ((RuleKey)iterator.Value).keyName;
        rowInfo.Cells[2].Value = ((RuleKey)iterator.Value).keyValue;

    ((GridViewLookUpColumn)radGridView_RuleKeys.Columns[1]).AutoCompleteMode = AutoCompleteMode.SuggestAppend; 
    ((GridViewLookUpColumn)radGridView_RuleKeys.Columns[1]).DropDownStyle = RadDropDownStyle.DropDown; 
    DataTable dt = new DataTable(); 
    ((GridViewLookUpColumn)radGridView_RuleKeys.Columns[1]).DataSource = dt; 

    If I make changes in the grid to cells in the third column, it works just fine. But I can't change the second column. When I type, it seems to be accepting whatever I'm typing, but when I hit enter, it goes away.

    I have two problems here.
    1) The value that I've manually set the cell to doesn't show up unless it's a member of the DataSource.
    2) The user cannot enter any value other than what is in the DataSource. If they type something in, it doesn't "stick". You hit Enter and the value reverts to whatever it was before.

    How do I go about addressing this? They both seem to be related. Is there a setting I'm missing or am I approaching this problem incorrectly?
  2. mtaber
    mtaber avatar
    12 posts
    Member since:
    Oct 2006

    Posted 31 Dec 2009 Link to this post

    So after a lot of beating my head against the wall, I basically found my answer here:

    I had also set the DisplayMember and ValueMember parameters, but was using a list as a datasource which also had some effect on this. If you can't figure out how to edit the contents of a GridViewLookUpColumn which is attached to a data source, use the link above. Works like a charm.

    The only thing to keep in mind is that the code in the CellEndEdit event specifies the column, so make sure you set this to the column you're using or it won't work.

  3. DevCraft R3 2016 release webinar banner
  4. Svett
    Svett avatar
    728 posts

    Posted 04 Jan 2010 Link to this post

    Hi mtaber,

    We are happy that you figured out the problem on your own. Let me know, if you need further assistance.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top