5 Replies - 5186 Views - Last Post: 12 November 2008 - 09:31 AM Rate Topic: -----

#1 sureshkvp85  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 07-November 08

DataGrid click event in VB 2005

Posted 11 November 2008 - 11:24 PM

i ve attached one bit map image file .....i want the output like that...if i click that datagrid...the correspoding value has displayed in the textbox.....now u understand my problem...i want coding for .net 2005

Attached File(s)

  • Attached File  dg.bmp (576.05K)
    Number of downloads: 141

Is This A Good Question/Topic? 0
  • +

Replies To: DataGrid click event in VB 2005

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: DataGrid click event in VB 2005

Posted 12 November 2008 - 01:09 AM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#3 sureshkvp85  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 07-November 08

Re: DataGrid click event in VB 2005

Posted 12 November 2008 - 02:10 AM

View Postsureshkvp85, on 11 Nov, 2008 - 10:24 PM, said:

i ve attached one bit map image file .....i want the output like that...if i click that datagrid...the correspoding value has displayed in the textbox.....now u understand my problem...i want coding for .net 2005


i ve return the following coding vb.net 2003 in datagrid click event
 Private Sub dg_employee_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles dg_employee.Click
		Dim names As Integer
		names = dg_employee(dg_employee.CurrentRowIndex, 0)
		str = "select * from tbl_employee where code=" & names & ""
		cmd2 = New SqlCommand(str, con)
		con.Open()
		dr = cmd2.ExecuteReader
		If dr.Read Then
			tbxcode.Text = dr(0)
			tbxname.Text = dr(1)
			tbxsalary.Text = dr(2)
		End If
	End Sub


it is working in vb.net 2003

but if write the same coding in vb.net2005
it shows the error in th following line
names=dg_employee(dg_employee.currentRowIndex,0)

wat i ve to do for this...
Was This Post Helpful? 1

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: DataGrid click event in VB 2005

Posted 12 November 2008 - 03:26 AM

Change this line

names=dg_employee(dg_employee.currentRowIndex,0)



To this line

names=dg_employee.Item(dg_employee.currentRowIndex,0)



Hope that helps :)
Was This Post Helpful? 0
  • +
  • -

#5 sureshkvp85  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 07-November 08

Re: DataGrid click event in VB 2005

Posted 12 November 2008 - 03:43 AM

View PostPsychoCoder, on 12 Nov, 2008 - 02:26 AM, said:

Change this line

names=dg_employee(dg_employee.currentRowIndex,0)



To this line

names=dg_employee.Item(dg_employee.currentRowIndex,0)



Hope that helps :)


[quote]

thanks for ur reply......u ve entered the following coding.....

names=dg_employee.Item(dg_employee.[b]currentRowIndex[/b],0)



but in vb.net2005 the above property currentrowindex is not there.....

its not working....wat i ve to do for this......
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: DataGrid click event in VB 2005

Posted 12 November 2008 - 09:31 AM

That's weird, as that's copied exactly from a test application I created for this problem (using VB 2005). In mine I have dg_employee.Item(dg_employee.CurrentRowIndex,0 )?

This is a DataGrid you're working with right?

EDIT: Here's a screen shot

Attached Image
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1