473,804 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,datagr id 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...m aybe an article to read?

' first I connect to MySQL and return a datatable
dvFinders = New DataView(dtFind ers) ' create dataview
' now I create the columns for my datagrid
Dim objDGTS As New DataGridTableSt yle
objDGTS.Alterna tingBackColor = Color.Beige
objDGTS.Mapping Name = "Finders"
' create textbox column
Dim objCol As New DataGridTextBox Column
objCol.MappingN ame = "findernumb er"
objCol.HeaderTe xt = " "
objCol.Width = 50
objDGTS.GridCol umnStyles.Add(o bjCol)
DataGrid1.Table Styles.Add(objD GTS)
' then I do the databinding
DataGrid1.SetDa taBinding(dvFin ders, "")

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 1574
Hi,

Call the DataAdapter.Upd ate Method.

Ken
--------------------------
"Bruce D" <br************ *@hotmail.com> wrote in message
news:11******** *****@corp.supe rnews.com...
I'm new to VB.NET and I think I may have a stupid question. I'm just now
understanding the dataview,datagr id 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...m aybe an article to read?

' first I connect to MySQL and return a datatable
dvFinders = New DataView(dtFind ers) ' create dataview
' now I create the columns for my datagrid
Dim objDGTS As New DataGridTableSt yle
objDGTS.Alterna tingBackColor = Color.Beige
objDGTS.Mapping Name = "Finders"
' create textbox column
Dim objCol As New DataGridTextBox Column
objCol.MappingN ame = "findernumb er"
objCol.HeaderTe xt = " "
objCol.Width = 50
objDGTS.GridCol umnStyles.Add(o bjCol)
DataGrid1.Table Styles.Add(objD GTS)
' then I do the databinding
DataGrid1.SetDa taBinding(dvFin ders, "")

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
3650
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
7038
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. Basically, what I want to do is that, on a button click, the dataset fills up dynamically, binds to the datagrid, and displays the data. This is my code: mySql = "select itemID, OrderDate " +
3
2210
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 here it don't exists. How can I resolve this problem? Tkx; Nic
3
6578
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 some rows, everything works fine. At the point that the rows returned by the rowfilter is cero (0), the datagrid don't get the rows even if I use a new rowfilter with results, the
1
2231
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 DataList by binding to a fresh SQLDataReader. At the moment I can only bind to the first instance of the DataList. If I could bind the data by the ClientID (or UniqueID), I'm sure it would work. Is there a way of doing this? Or maybe there is a better...
8
1918
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 my localhost on my development machine. The database is on the web. When I run the app on the local machine, IE opens, loads my aspx page from localhost, and hangs. (Eventually I get a page cannot be displayed error.)
7
11931
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 oResponse.historicalData.Length - 1 ) no problem to load a datagrid. However, when I try to bind directly the datasource to the web service
13
5350
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 would like to do (of course) is set the DataBindings. Something clearly is wrong with the approach I use, because I can't set the Properties in the Designer, the DataSource-Property appears like 'ReadOnly', there is no "dropdown" with the list from...
8
2189
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 answered... In 1.1 we always did our own myDataAdapter.fills and we liked that control for lots of good reasons. Now the new DataSource (or is it a TableAdapter:Dataset) automatically fills the Gridview. How can we control that fill? In a...
0
10599
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10346
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10347
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.