i have the following code

Dim i As Integer

        i = Me.GridDomains.CurrentRow.Index
        Me.lbdomainid.Text = GridDomains.Item(0, i).Value

when i have complied it in visual studio 2010 (debug)

i get a error saying

system.data.sqlclient.sqlexceptions conversion faild when converting varchar value LBdomainID to data type int.

in sql the datatype is INT - i dont know what to do with the code above to remove this error

i have tryied
Cint(GridDomains.Item(0, i).Value).tostring but this doesnt work. thought i was so close with finishing my first .net program but was so wrong.

please help

Recommended Answers

All 4 Replies

try this

Dim j As String
   
      j = Me.GridDomains.CurrentRow.Index
      Dim i As Integer = Integer.Parse(j)
      Me.lbdomainid.Text = GridDomains.Item(0, i).Value

hope this helps you

hi thanks for this, i am unsure what this actualy does.

what i need it the lable if posible to contact a Int value from my Griddomains grid

ps i have tried this and it still comes up with the error

ok this should work

Dim j As String
      j = Me.GridDomains.CurrentRow.Index
      Dim i As Integer = Integer.Parse(j)
      Me.lbdomainid.Text = GridDomains.Rows(i).Cells(0).Value

if you get an error with the code GridDomains.Rows(i).Cells(0).Value then change to
GridDomains.Rows(i).Cells(0).Value.ToString

hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.