cant show data ini the combo box

my combo box is indside a datagrid view

Page 1 of 1

2 Replies - 1737 Views - Last Post: 28 December 2008 - 07:03 AM Rate Topic: -----

#1 rocks_lp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-December 08

cant show data ini the combo box

Posted 24 December 2008 - 11:17 PM

i have a datagrid. i populating it with data.

THIS IS MY CODE :
cmdSelect = New OleDbCommand(sql, conn)
		daSelect = New OleDbDataAdapter(cmdSelect)

		daSelect.Fill(dsCredit, "Credit")
		count = dsCredit.Tables(0).Rows.Count
		MsgBox(count)

		Try

			dgCredit.Rows(0).Cells(0).Value = dsCredit.Tables(0).Rows(0).Item(0).ToString

			dgCredit.Rows(0).Cells(1).Value = dsCredit.Tables(0).Rows(0).Item(1).ToString

			dgCredit.Rows(0).Cells(2).Value = dsCredit.Tables(0).Rows(0).Item(3).ToString

			dgCredit.Rows(0).Cells(3).Value = dsCredit.Tables(0).Rows(0).Item(4).ToString

			dgCredit.Rows(0).[color=#3333FF]Cells(4)[/color].Value = dsCredit.Tables(0).Rows(0).Item(5).ToString

			dgCredit.Rows(0).[color=#3333FF]Cells(5)[/color].Value = dsCredit.Tables(0).Rows(0).Item(6).ToString

			dgCredit.Rows(0).[color=#3333FF]Cells(6)[/color].Value = dsCredit.Tables(0).Rows(0).Item(7).ToString

			dgCredit.Rows(0).[color=#3333FF]Cells(7)[/color].Value = dsCredit.Tables(0).Rows(0).Item(8).ToString

			dgCredit.Rows(0).[color=#3333FF]Cells(8)[/color].Value = dsCredit.Tables(0).Rows(0).Item(9).ToString

		Catch ex As Exception

			err = ex.ToString
			MsgBox(err)

		End Try




END CODE:

my cell 4,5,6,7,8 are datagridview combo box cell.

ERROR I AM GETTING

System.ArgumentExcemption:DatagridviewComboBoxCell Value is not valid

Is This A Good Question/Topic? 0
  • +

Replies To: cant show data ini the combo box

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4332
  • View blog
  • Posts: 12,127
  • Joined: 18-April 07

Re: cant show data ini the combo box

Posted 25 December 2008 - 05:51 PM

First of all this solution you are showing is a classic red flag that perhaps you should be implementing a loop since everything is identical except for the subscripts. So look into that.

Second, the error typically arises when you are trying to put an invalid value into your Cells.Value property. Keep in mind that the two values must be of the same type. So make sure that Cells 4, 5, 6, 7, 8 type on the left is the SAME TYPE as the ones on the right. Almost make sure you actually have a value on the right.

So for instance if dgCredit.Rows(0).Cells(3).Value is expecting a char and you are pulling a value out of dsCredit.Tables is also a char. Also it is important that you are actually returning a value. You can find this out by putting a debug stop point on this line and hovering over the toString part to see what value is about to be dumped into the cell. Make sure the two are compatible.

:)
Was This Post Helpful? 0
  • +
  • -

#3 rocks_lp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 24-December 08

Re: cant show data ini the combo box

Posted 28 December 2008 - 07:03 AM

View PostMartyr2, on 25 Dec, 2008 - 04:51 PM, said:

First of all this solution you are showing is a classic red flag that perhaps you should be implementing a loop since everything is identical except for the subscripts. So look into that.

Second, the error typically arises when you are trying to put an invalid value into your Cells.Value property. Keep in mind that the two values must be of the same type. So make sure that Cells 4, 5, 6, 7, 8 type on the left is the SAME TYPE as the ones on the right. Almost make sure you actually have a value on the right.

So for instance if dgCredit.Rows(0).Cells(3).Value is expecting a char and you are pulling a value out of dsCredit.Tables is also a char. Also it is important that you are actually returning a value. You can find this out by putting a debug stop point on this line and hovering over the toString part to see what value is about to be dumped into the cell. Make sure the two are compatible.

:)


tank you dis helped me alot
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1