473,395 Members | 2,796 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,395 software developers and data experts.

Databinding in Datagrid??

I'm new to VB.NET and I think I may have a stupid question. I'm just now
understanding the dataview,datagrid relationship. I have created a dataview
from a MySQL database. I'm doing everything programatically. So, I have
this datagrid on my form which displays the data from my tables...my
question...if I edit a field in the grid, how do I update the database?
Here's a small example of what I'm doing. I'm lost...any help is
appreciated...maybe an article to read?

' first I connect to MySQL and return a datatable
dvFinders = New DataView(dtFinders) ' create dataview
' now I create the columns for my datagrid
Dim objDGTS As New DataGridTableStyle
objDGTS.AlternatingBackColor = Color.Beige
objDGTS.MappingName = "Finders"
' create textbox column
Dim objCol As New DataGridTextBoxColumn
objCol.MappingName = "findernumber"
objCol.HeaderText = " "
objCol.Width = 50
objDGTS.GridColumnStyles.Add(objCol)
DataGrid1.TableStyles.Add(objDGTS)
' then I do the databinding
DataGrid1.SetDataBinding(dvFinders, "")

The grid looks good on the form. I have a save button on the form. I don't
know what to do to update the database if I edit the 'findernumber' on the
grid.

-bruce d


Nov 21 '05 #1
1 1549
Hi,

Call the DataAdapter.Update Method.

Ken
--------------------------
"Bruce D" <br*************@hotmail.com> wrote in message
news:11*************@corp.supernews.com...
I'm new to VB.NET and I think I may have a stupid question. I'm just now
understanding the dataview,datagrid relationship. I have created a dataview
from a MySQL database. I'm doing everything programatically. So, I have
this datagrid on my form which displays the data from my tables...my
question...if I edit a field in the grid, how do I update the database?
Here's a small example of what I'm doing. I'm lost...any help is
appreciated...maybe an article to read?

' first I connect to MySQL and return a datatable
dvFinders = New DataView(dtFinders) ' create dataview
' now I create the columns for my datagrid
Dim objDGTS As New DataGridTableStyle
objDGTS.AlternatingBackColor = Color.Beige
objDGTS.MappingName = "Finders"
' create textbox column
Dim objCol As New DataGridTextBoxColumn
objCol.MappingName = "findernumber"
objCol.HeaderText = " "
objCol.Width = 50
objDGTS.GridColumnStyles.Add(objCol)
DataGrid1.TableStyles.Add(objDGTS)
' then I do the databinding
DataGrid1.SetDataBinding(dvFinders, "")

The grid looks good on the form. I have a save button on the form. I don't
know what to do to update the database if I edit the 'findernumber' on the
grid.

-bruce d

Nov 21 '05 #2

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

Similar topics

4
by: CGuy | last post by:
Hi, I have an ASPX page which has a datagrid and this datagrid is bound to a Custom Collection. sample code this.DataGrid1.DataSource = UserManager.Users; this.DataGrid1.DataBind();
4
by: John | last post by:
Hello all, I'm trying to display a dataset into a datagrid and format the datagrid columns but I'm having a hard time with it. I've tried the MSDN examples but they don't seem to work. ...
3
by: Nic | last post by:
Hey, I have an ASP-application. In the ASPX I have an <asp:dropdownlist ..>. Now when I leave this control I want to initialisize some other fields. In window forms we uses the onleave event but...
3
by: MajorTom | last post by:
Hello I need help. I have a datagrid that have a dataview as datasource. in the keyup event of one textbox I use dataview.rowfilter = some.text; when the condition of my rowfilter return...
1
by: oafyuf | last post by:
Hi, I'm trying to learn ASP.NET by doing a pilot project: I have a DataGrid which contains a nested DataList. I want to iterate through the SQLDataReader for the DataGrid and populate each...
8
by: Jeff | last post by:
Hi - I'm having trouble Databinding a SQLDataReader to a DataGrid control. I have an ASP.NET web page accessing a SQL database. I've used VS to build the app and stored it in a directory of...
7
by: BS | last post by:
Hello everybody I'm calling a webservice that returns complex data. The goal is to populate a datagrid with it. Using a loop for each record found ( such as For i = 0 To...
13
by: Michael Maes | last post by:
Hi, I have a UserControl containing some controls of which one is a ComboBox. All the InternalControls are Private and some are allowed to be accessed through Public Methods. One of the things I...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.