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

[Solved] GridBoundColumn from enum

3 Answers 252 Views
Grid
This is a migrated thread and some comments may be shown as answers.
khetto
Top achievements
Rank 1
khetto asked on 21 Apr 2008, 09:20 PM

Is there a simple way to bind a GridDropDownColumn to an enum?

By the way, the "Automatic operations"sample does not work for me when In-line edit is selected. I try to change any dropdown and then update the row and I get redirected to an un-existing page.

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 22 Apr 2008, 06:32 AM
Hello khetto,

I just checked our example and everything works fine:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/DataEditing/AllEditableColumns/DefaultCS.aspx

You can use the same approach with ObjectDataSource where you can return desired data source for the GridDropDownColumn.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
khetto
Top achievements
Rank 1
answered on 22 Apr 2008, 05:08 PM

Thanks for the quick reply.

The failing demo I ment its at: http://www.telerik.com/demos/aspnet/Grid/Examples/DataEditing/AllEditableColumns/DefaultCS.aspx

Is this an old version?

About the DataSource object. Do you have a sample implementation at hand?

0
khetto
Top achievements
Rank 1
answered on 22 Apr 2008, 09:18 PM

Got it working.

In case someone needs it:

<

asp:ObjectDataSource ID="dsSomeEnum" runat="server" 
    SelectMethod="GetSomeEnum"
    TypeName="EnumsSources">
</asp:ObjectDataSource>

public

enum SomeEnum
{
    Enum1,
    Enum2
}

public

static class EnumsSources
{
    public static ListItemCollection GetSomeEnum()
    {
        ListItemCollection rtnItems = new ListItemCollection();
        foreach (string item in Enum.GetNames(typeof(SomeEnum)))
        {
            int value = (int)Enum.Parse(typeof(SomeEnum), item);
            ListItem listItem = new ListItem(item, value.ToString());
            rtnItems.Add(listItem);
        }
        return rtnItems;
    }
}

Any simplier?

Tags
Grid
Asked by
khetto
Top achievements
Rank 1
Answers by
Vlad
Telerik team
khetto
Top achievements
Rank 1
Share this question
or