473,385 Members | 1,333 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,385 software developers and data experts.

Updating Datagrid not working

Please help, i have to finish this assignment ASAP.
the project is to create a solution with 3 text box for FactoryID, FactoryName and FactoryAddress. next is to create 2 Datagrid for Customer and Supplier.
Splash screen also create for start up the program.
i have created most of the program but could not figure it out how to get the relationsive to work between Factory, Customer and the supplier.
please reply.
May 31 '07 #1
8 1351
SammyB
807 Expert 512MB
Welcome to TheScripts! Please read Homework Guidelines and post back with a specific problem. Thanks!
May 31 '07 #2
Welcome to TheScripts! Please read Homework Guidelines and post back with a specific problem. Thanks!
Thanks for the advice.
I have created form with text box (FactoryID, FactoryName and Address etc.)
and created 2 datagrid to display Customer info (FactoryID, CustomerID etc.) the second datagrid is Supplier (FactoryID, SupplierID etc.).
i have finished all of the above, created all the necessary connection (OleDbConnection, OleDbDatasdapter and Dataset) to the Main form.
MMuMain also created to navigate (First, Previous, next etc,). however when i click on next or previous the text box for the factoryID, address and name change accordingly, but the datagrid does not change according to the factory text box. like i had mentioned in the previous i have problems of understanding of how to setup the relationsive/or code?.
please advise.
Jun 1 '07 #3
Frinavale
9,735 Expert Mod 8TB
Thanks for the advice.
I have created form with text box (FactoryID, FactoryName and Address etc.)
and created 2 datagrid to display Customer info (FactoryID, CustomerID etc.) the second datagrid is Supplier (FactoryID, SupplierID etc.).
i have finished all of the above, created all the necessary connection (OleDbConnection, OleDbDatasdapter and Dataset) to the Main form.
MMuMain also created to navigate (First, Previous, next etc,). however when i click on next or previous the text box for the factoryID, address and name change accordingly, but the datagrid does not change according to the factory text box. like i had mentioned in the previous i have problems of understanding of how to setup the relationsive/or code?.
please advise.
How have you tried changing the DataGrid?
Could you post a snippet of your code relating to this functionality so that we have a better idea of what you're doing?

Thanks

-Frinny
Jun 1 '07 #4
Below is the code from Main. Please asvice.
Expand|Select|Wrap|Line Numbers
  1.  Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Dim printRecords As Integer
  3.         Dim dgtsCustomer As New DataGridTableStyle()
  4.         Dim dgtsSupplier As New DataGridTableStyle()
  5.         Dim pbndTemp As Binding
  6.         Dim dtCustomers As DataTable
  7.  
  8.         ODbDaFactory.Fill(DsFactory3)
  9.  
  10.         Call EditState(cblnNotEditing)
  11.  
  12.         dgtsCustomer.AlternatingBackColor = Color.LightBlue
  13.         dgtsCustomer.GridLineColor = Color.Silver
  14.         dgtsCustomer.GridLineStyle = DataGridLineStyle.Solid
  15.         dgtsCustomer.SelectionForeColor = Color.Blue
  16.         dgtsCustomer.SelectionBackColor = Color.Silver
  17.         dgtsCustomer.MappingName = _
  18.         DsFactory.tblCustomer.TableName
  19.         dgCustomer.TableStyles.Add(dgtsCustomer)
  20.  
  21.         'Customer, Formt the datagrid columns.
  22.         dgtsCustomer.GridColumnStyles(0).HeaderText = "Factory ID"
  23.         dgtsCustomer.GridColumnStyles(0).Alignment = _
  24.         HorizontalAlignment.Center
  25.         dgtsCustomer.GridColumnStyles(1).HeaderText = "Customer ID"
  26.         dgtsCustomer.GridColumnStyles(1).Alignment = _
  27.         HorizontalAlignment.Center
  28.         dgtsCustomer.GridColumnStyles(2).HeaderText = "Name"
  29.         dgtsCustomer.GridColumnStyles(2).Alignment = _
  30.         HorizontalAlignment.Center
  31.         dgtsCustomer.GridColumnStyles(3).HeaderText = "Address"
  32.         dgtsCustomer.GridColumnStyles(3).Alignment = _
  33.         HorizontalAlignment.Center
  34.         dgtsCustomer.GridColumnStyles(4).HeaderText = "City"
  35.         dgtsCustomer.GridColumnStyles(4).Alignment = _
  36.         HorizontalAlignment.Center
  37.         dgtsCustomer.GridColumnStyles(5).HeaderText = "State"
  38.         dgtsCustomer.GridColumnStyles(5).Alignment = _
  39.         HorizontalAlignment.Center
  40.         dgtsCustomer.GridColumnStyles(6).HeaderText = "Zip Code"
  41.         dgtsCustomer.GridColumnStyles(6).Alignment = _
  42.         HorizontalAlignment.Center
  43.         dgtsCustomer.GridColumnStyles(7).HeaderText = "Credit Limit"
  44.         dgtsCustomer.GridColumnStyles(7).Alignment = _
  45.         HorizontalAlignment.Center
  46.         dgtsCustomer.GridColumnStyles(8).HeaderText = "Balance Due"
  47.         dgtsCustomer.GridColumnStyles(8).Alignment = _
  48.         HorizontalAlignment.Center
  49.  
  50.         'Supplier, Formt the datagrid columns
  51.         dgtsSupplier.AlternatingBackColor = Color.LightBlue
  52.         dgtsSupplier.GridLineColor = Color.Silver
  53.         dgtsSupplier.GridLineStyle = DataGridLineStyle.Solid
  54.         dgtsSupplier.SelectionForeColor = Color.Blue
  55.         dgtsSupplier.SelectionBackColor = Color.Silver
  56.         dgtsSupplier.MappingName = _
  57.         DsFactory.tblSupplier.TableName
  58.         dgSupplier.TableStyles.Add(dgtsSupplier)
  59.  
  60.         dgtsSupplier.GridColumnStyles(0).HeaderText = "Factory ID"
  61.         dgtsSupplier.GridColumnStyles(0).Alignment = _
  62.         HorizontalAlignment.Center
  63.         dgtsSupplier.GridColumnStyles(1).HeaderText = "Supplier ID"
  64.         dgtsSupplier.GridColumnStyles(1).Alignment = _
  65.         HorizontalAlignment.Center
  66.         dgtsSupplier.GridColumnStyles(2).HeaderText = "Supplier Name"
  67.         dgtsSupplier.GridColumnStyles(2).Alignment = _
  68.         HorizontalAlignment.Center
  69.         dgtsSupplier.GridColumnStyles(3).HeaderText = "Address"
  70.         dgtsSupplier.GridColumnStyles(3).Alignment = _
  71.         HorizontalAlignment.Center
  72.         dgtsSupplier.GridColumnStyles(4).HeaderText = "City"
  73.         dgtsSupplier.GridColumnStyles(4).Alignment = _
  74.         HorizontalAlignment.Center
  75.         dgtsSupplier.GridColumnStyles(5).HeaderText = "State"
  76.         dgtsSupplier.GridColumnStyles(5).Alignment = _
  77.         HorizontalAlignment.Center
  78.         dgtsSupplier.GridColumnStyles(6).HeaderText = "Zip Code"
  79.         dgtsSupplier.GridColumnStyles(6).Alignment = _
  80.         HorizontalAlignment.Center
  81.         dgtsSupplier.GridColumnStyles(7).HeaderText = "Credit Limit"
  82.         dgtsSupplier.GridColumnStyles(7).Alignment = _
  83.         HorizontalAlignment.Center
  84.  
  85.  
  86.  
  87.     End Sub
  88.  
  89.  
  90.  
  91.     Private Sub dgCustomer_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgCustomer.CurrentCellChanged
  92.         Dim drArray() As DataRow
  93.         Dim pintFactoryId As Integer
  94.         Dim pintCount As Integer
  95.         Dim pintFactoryName As String
  96.         Dim pintFactoryAddress As String
  97.  
  98.         drArray = DsFactory.tblCustomer(dgCustomer.CurrentRowIndex).GetChildRows _
  99.         ("drtblCustomer")
  100.  
  101.         pintFactoryId = drArray.GetUpperBound(0) + 1
  102.         txtFactoryId.Text = pintFactoryId.ToString
  103.  
  104.         txtFactoryId.Text = pintFactoryId.ToString
  105.  
  106.     End Sub
Jun 4 '07 #5
Frinavale
9,735 Expert Mod 8TB
Below is the code from Main. Please asvice.
Expand|Select|Wrap|Line Numbers
  1.  Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         Dim printRecords As Integer
  3.         Dim dgtsCustomer As New DataGridTableStyle()
  4.         Dim dgtsSupplier As New DataGridTableStyle()
  5.         Dim pbndTemp As Binding
  6.         Dim dtCustomers As DataTable
  7.  
  8.       ..
  9.     End Sub
  10.  
  11.  
  12.  
  13.     Private Sub dgCustomer_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgCustomer.CurrentCellChanged
  14.         Dim drArray() As DataRow
  15.         Dim pintFactoryId As Integer
  16.         Dim pintCount As Integer
  17.         Dim pintFactoryName As String
  18.         Dim pintFactoryAddress As String
  19.  
  20.         drArray = DsFactory.tblCustomer(dgCustomer.CurrentRowIndex).GetChildRows _
  21.         ("drtblCustomer")
  22.  
  23.         pintFactoryId = drArray.GetUpperBound(0) + 1
  24.         txtFactoryId.Text = pintFactoryId.ToString
  25.  
  26.         txtFactoryId.Text = pintFactoryId.ToString
  27.  
  28.     End Sub
It appears that you are taking the content from your data set and filling text boxes with the data.

I don't see where you are changing the view of the dataGrid.
I still don't understand your use of the "Next" and "Previous" buttons.

Are you using the Next and Previous buttons to allow the user to update data in your dataSet? Then want to update your dataGrid with this new data showing?

Can you not just use "RowEditing" and "RowUpdating" to allow the user to do their updating in the dataGrid?

I'm sorry but I still don't understand what you're trying to accomplish.

-Frinny
Jun 5 '07 #6
Here is the navigates for first, previous, next and last.
How can i change datagrid when i click on next or previous. should i create the relationship between factory, customer and supplier. please advice.
Expand|Select|Wrap|Line Numbers
  1. Private Sub mmuNavigateFirst_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mmuNavigateFirst.Click
  2.         Me.BindingContext(DsFactory3, "tblfactory").Position = 0
  3.     End Sub
  4.  
  5.  
  6.     Private Sub mmuNavigatePrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mmuNavigatePrevious.Click
  7.         Me.BindingContext(DsFactory3, "tblfactory").Position -= 1
  8.     End Sub
  9.  
  10.        Private Sub mmuNavigateNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mmuNavigateNext.Click
  11.         Me.BindingContext(DsFactory3, "tblfactory").Position += 1
  12.  
  13.     End Sub
  14.  
  15.       Private Sub mmuNavigateLast_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mmuNavigateLast.Click
  16.         Me.BindingContext(DsFactory3, "tblfactory").Position = Me.DsFactory3.tblFactory.Rows.Count - 1
  17.     End Sub
  18.  
Jun 5 '07 #7
Frinavale
9,735 Expert Mod 8TB
Here is the navigates for first, previous, next and last.
How can i change datagrid when i click on next or previous. should i create the relationship between factory, customer and supplier. please advice.
Expand|Select|Wrap|Line Numbers
  1. Private Sub mmuNavigateFirst_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mmuNavigateFirst.Click
  2.         Me.BindingContext(DsFactory3, "tblfactory").Position = 0
  3.     End Sub
  4.  
  5.  
  6.     Private Sub mmuNavigatePrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mmuNavigatePrevious.Click
  7.         Me.BindingContext(DsFactory3, "tblfactory").Position -= 1
  8.     End Sub
  9.  
  10.        Private Sub mmuNavigateNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mmuNavigateNext.Click
  11.         Me.BindingContext(DsFactory3, "tblfactory").Position += 1
  12.  
  13.     End Sub
  14.  
  15.       Private Sub mmuNavigateLast_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mmuNavigateLast.Click
  16.         Me.BindingContext(DsFactory3, "tblfactory").Position = Me.DsFactory3.tblFactory.Rows.Count - 1
  17.     End Sub
  18.  
Please check out MSDN's article on DataGrids and their members and MSDN's Article on DataGrid Events.

I cannot understand your problem.
A dataGrid shows many rows...not just one...so there's no need to use "next' and "previous".

A dataGrid could show all of the rows in your dataSet if you'd like it to...then users just have to glance through the dataGrid to find the row that they'd want to edit.

A dataGrid also has Paging functionality......which can take you to the first row or the last row in the dataGrid.

Why can't you just use the update functionality that is built into the dataGrid? Let the user look at the information in the grid, let them select "edit"...let them edit the information inside the grid....This will simplify your problem quite a bit.

I'm going to ask other experts to take a look at your problem and hopefully we can help you get through this.

-Frinny
Jun 5 '07 #8
giveDsolution
107 100+
Why dunt u try Gridview Paging...

Set Allowpaging true
then write the code in vb Page.....

Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
Me.GridView1.PageIndex = e.NewPageIndex
fillgrid() [Call the fuction to fill gridview]

End Sub
It may solve ur problem
Jun 6 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to...
4
by: A P | last post by:
Hi! I'm a new user of VB.NET 2003 and still learning its feature, one of them is datagrid. I am using Access 2002 Database on my project and trying to update values of a table using datagrid...
9
by: A P | last post by:
Hi! I have created a sample datagrid that can update data on a database. Please help me solve the problem, I have attached both aspx and code behind (aspx.vb): ______________________ ...
1
by: A P | last post by:
Hi! I'm a new user of VB.NET 2003 and still learning its feature, one of them is datagrid. I am using Access 2002 Database on my project and trying to update values of a table using datagrid...
0
by: cwbp17 | last post by:
Have two tables that have a FK relationship on ID column. Have one datagrid that displays all of the columns of both tables. What's the best approach on updating a row from the datagrid back to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.