473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DataGrid Trouble / Help

VB 2005 express...

I created a database "Staff" and it has 1 table in it.
There are 3 columns in it so far.
"StaffID" -INT - Primary Key auto incremented by 1
"FirstName" - Varchar
"LastName" - varchar
( there will be more later - but baby steps )

Then I created 2 forms.
Form1 is the main form where I dragged the datagrid to the form.

Now I made the Datagrid.SelectionMode = FullRowSelect
and the datagrid is not editable.

Now On Form2 I created a property that is going to store the "StaffID"
This form I am going to try to code all "without a wizard".

====
Dim iStaffMember As Integer = ""

Public Property StaffMember() As Integer
Get
Return iStaffMember
End Get
Set(ByVal Value As Integer)
iStaffMember = Value
End Set
End Property
===

So now back on Form1 right before I try to "Form2.SHOW()" I try to set
that property from the datagrid so i can do my "own select" statement in
form 2 to show the detail's of the data.
( Example like: Select * from Staff where StaffID = StaffMemberProperty )

But I just cant seem to get the property set correctly

Dim fStaffMember as New Form2
fStaffMember.StaffMember =
Me.StaffDataSet.Staff.Rows(Me.StaffDataGridView.Cu rrentCell.RowIndex)("StaffID")

first off, the CurrentCell.RowIndex is incorrect - since I allow
resorting by column, its actually not the correct index from the dataset.

2nd, I get a convert error.

What is the parameter I should be using to get the "row#" from the bound
dataset?
And what Datatype should by Property be dim'd as?

Thanks

Miro
Oct 8 '07 #1
2 1115
Hi,Miro

"Miro" wrote in message
news:uM*************@TK2MSFTNGP06.phx.gbl
Dim iStaffMember As Integer = ""
You can't set String to Integer,so
Dim iStaffMembeer as Integer=-1
Dim fStaffMember as New Form2
fStaffMember.StaffMember =
Me.StaffDataSet.Staff.Rows(Me.StaffDataGridView.Cu rrentCell.RowIndex)("StaffID")
directcast(Me.StaffDataGridView.CurrentRow.DataBou ndItem,
DataRowView).Row.Item("StaffID")

Oct 9 '07 #2
yuichiro ochifuji wrote:
Hi,Miro

"Miro" wrote in message
news:uM*************@TK2MSFTNGP06.phx.gbl
>Dim iStaffMember As Integer = ""

You can't set String to Integer,so
Dim iStaffMembeer as Integer=-1
>Dim fStaffMember as New Form2
fStaffMember.StaffMember =
Me.StaffDataSet.Staff.Rows(Me.StaffDataGridView.C urrentCell.RowIndex)("StaffID")

directcast(Me.StaffDataGridView.CurrentRow.DataBou ndItem,
DataRowView).Row.Item("StaffID")
I have just figured this out, just as you posted your post for me,

Dim bmStaff As BindingManagerBase =
Me.StaffDataGridView.BindingContext(Me.StaffDataGr idView.DataSource,
Me.StaffDataGridView.DataMember)
Dim dr As DataRow = CType(bmStaff.Current, DataRowView).Row

frmMain.fStaffMember.StaffMember = CInt(dr("StaffID"))

I tried yours and had to put a CInt( around your directcast.

Im assuming both our codes are doing the same thing?

Thanks,

Miro
Oct 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Frnak McKenney | last post by:
I have a (small) multi-table database application which allows edits, print reports, and has two scrolling screen displays which show information merged from multiple tables. I'm having trouble...
3
by: Fortra | last post by:
I'm having trouble with the UpdateCommand event with the DataGrid control. The event is wired up in the InitializeComponents properly, this.sitesDataGrid.UpdateCommand += new...
1
by: Guy Noir | last post by:
I am having trouble wrapping my head around a datagrid and datasource. I have it working, sort-of, but I'm having trouble refreshing my views. Here's what I have: A dataAdapter and dataSet...
2
by: martin | last post by:
Hi, I am iterating through the dataitems in a datagrid and producing and xml document, If a particular cell in the datagrid has a textbox control or a datagrid control in it then I have no...
2
by: student | last post by:
Hi all, I'm having trouble with my datagrid, it is suppose to display a row from a table called "Calls" based on what is selected in the dropdownlist which displays the first and last name from...
1
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). ...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
1
by: ghommel | last post by:
I really, really hope someone can help me. this is a very urgent need. for some reason it seems like no one is knowledgeable enough, myself included, to know the answer. I am trying to make a...
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
0
by: sumitdipsite2005 | last post by:
I am trying to use VB6 as a middleware between two 3rd party applications. "App. A" ----> VB6 ------> "App B" i am having no trouble sending data from VB to the "App B". But i am having...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.