Object ID in DataGrid

Last post 06-17-2009 10:08 AM by alaric. 2 replies.

Sort Posts:

  • Object ID in DataGrid

    06-17-2009, 3:15 AM
    • Member
      1 point Member
    • alaric
    • Member since 06-17-2009, 1:55 AM
    • Posts 2

    Hi guys,

    I have bit of a problem with displaying a list of objects along with their IDs (unique identifiers) in the DataGrid. So, DataGrid shows properties of selected objects correctly, but I cannot associate ID (which is long) with the objects and not to show it in the grid.

    Here is an example (I am using Eloquera DB):

     

    Dictionary<long, User> idUsers = new Dictionary<long, User>();
    
    var users = db.ExecuteQuery("SELECT User WHERE Active = true");
    foreach (var user in users)
      idUsers.Add(db.GetUid(user), user as User);
     

    I need to use this ID to get access to the same object on the postback (e.g., for delete or update).

    Is there any way to store that ID without showing it in DataGrid?

    Filed under: ,
  • Re: Object ID in DataGrid

    06-17-2009, 9:35 AM
    Answer
    • Contributor
      5,138 point Contributor
    • papabear
    • Member since 08-08-2005, 3:49 PM
    • Posts 851

    Is there a reason not to use a GridView? It has the DataKeyNames property which is exactly what you are looking for. Plus it has a lot of nice events that you can handle (sorting, paging, etc).

    Hope this helps,

    m

    give me suggestions for what to blog... http://www.myfriedmind.com/techblog -> thx

    Mark as "Answered" if this solves that wee old problem...
  • Re: Object ID in DataGrid

    06-17-2009, 10:08 AM
    • Member
      1 point Member
    • alaric
    • Member since 06-17-2009, 1:55 AM
    • Posts 2
    Actually, I needed a light-weight component for displaying IEnumerable that Eloquera returns. That is the only reason for choosing DataGrid. If DataGrid cannot handle object IDs, so I'll switch to GridView. Thanks papabear!
    Filed under: ,
Page 1 of 1 (3 items)