Results 1 to 4 of 4

Thread: Getting selected row ID

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Getting selected row ID

    Guys,

    I am using a C1TrueGrid (ARGHHHH). I am trying to get the id of the selected row, I have grouping applied so the normal methods are giving me the grouped row ID. Really annoying. In their manual, they give this code, but I can't get this working. I'm getting the error at the bottom of the code.

    I know its difficult when I'm using non standard controls, but can anybody see the problem ? C1support are not good at giving fast and concise solutions to these issues.

    Thanks in advance,
    Bob

    VB Code:
    1. Dim dv As System.Data.DataView()
    2.             Dim cm As CurrencyManager
    3.             cm = CType(Me.BindingContext.Item(Me._tgDocLog.DataSource, Me._tgDocLog.DataMember), CurrencyManager)
    4.             dv = cm.List
    5.             Dim dr As System.Data.DataRow = Me._tgDocLog(Me._tgDocLog.Row)
    6.  
    7.             'ERROR - Value of type 'IList' cannot be converted to '1-dimensional array of DataView'.
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Getting selected row ID

    The fact that you have parentheses after the type in the first line means that you have declared a DataView array, not a single DataView.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Re: Getting selected row ID

    Thanks jmc,

    I am now getting a specified cast not valid on this line...
    Dim dr As System.Data.DataRow = Me._tgDocLog(Me._tgDocLog.Row)

    Bob
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Getting selected row ID

    I've never used that control so I don't know all the ins and outs, but I'd think that if you wanted the DataRow that corresponded to the selected row in the grid then you'd have to go through the DataSource which is you DataView. I'd guess that you should be able to index the DataView by the Position property of the CurrencyManager to get a DataRowView, which has a Row property that is a DataRow from the original DataTable, which I guess is what you want. I'm guessing from your code that the Row property of the grid would give you the same value as the Position property of the CurrencyManager. In short, either of these should work, I think:
    VB Code:
    1. Dim dr As System.Data.DataRow = dv(Me._tgDocLog.Row).Row
    VB Code:
    1. Dim dr As System.Data.DataRow = dv(cm.Position).Row
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width