• 0

VB.net datagrid editing


Question

4 answers to this question

Recommended Posts

  • 0

I don't have time to explain this in detail, but here's the basics...

1. Right click your datagrid and go to 'Property Builder'. Go to the 'Columns' section.

2. Add an 'Edit, Update and Cancel' column from the 'Button Column' node. Click OK.

3. In the code behind, select the DataGrid from the drop down list at the top left, then select the 'Edit Command' from the drop down list at the top right of the page. This will create the subroutine that is called when you click the 'Edit' button on the datagrid.

4. You need to do this for the 'Update Command' as well. In this sub (which is for the 'Update' button) you'll need to add code to set the new values in the dataset and then update the dataset and re-bind the datagrid.

5. You should also create a subroutine for the cancel button.

The code for the edit button is something like:

Datagrid1.EditItemIndex = e.Item.ItemIndex
DataGrid1.DataBind

The code for the cancel button is something like:

DataGrid1.EditItemIndex = -1
DataGrid1.DataBind

hope that gives you something to work with

  • 0

I tried using the wizard, but it doesn't work for MYSQL databases (I can't afford SQL server). I found the following link http://msdn.microsoft.com/library/default....pterDataSet.asp and tried to adapt it to mysql, but I can't get it to work. Here is my code:

Protected Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click

myDataSet.AcceptChanges() 'when I don't have this, it throws a system error with no description

darAdapter.UpdateCommand = New MySQLCommand("UPDATE RequestedInventoryItems SET Quantity = @Quantity" & _

"WHERE ID = @ID", conMysql) 'conMysql is the MySQLConnection

darAdapter.UpdateCommand.Parameters.Add("@QuantityMyMySQLDbType.Int24, "Quantity")

Dim workParm As MySQLParameter = darAdapter.UpdateCommand.Parameters.Add("@IDMyMySQLDbType.Int24)

workParm.SourceColumn = "ID"

workParm.SourceVersion = DataRowVersion.Original

darAdapter.Update(myDataSet.Tables("Inventory"))

End Sub

PLEASE HELP! :wacko:

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Stellarium 25.2 by Razvan Serea Stellarium is a free open source planetarium for your computer. It shows a realistic sky in 3D, just like what you see with the naked eye, binoculars or a telescope. It is being used in planetarium projectors. Just set your coordinates and go. Stellarium key features: Realistic simulation of the sky, sunrise and sunset Default catalogue of over 600,000 stars Downloadable additional catalogues for up to 210 million stars Catalog data for all New General Catalogue (NGC) objects Images of almost all Messier objects and the Milky Way Artistic illustrations for all 88 modern constellations More than a dozen different cultures with their constellations Solar and lunar eclipse simulation Photorealistic landscapes (more are available on the website) Scripting support with ECMAScript (a few demo scripts are included) Extendable with plug-ins: 8 plug-ins installed by default, including: artificial satellites plug-in (updated from an on-line TLE database) ocular simulation plug-in (shows how objects look like in a given ocular) Solar System editor plug-in (imports comet and asteroid data from the MPC) telescope control plug-in (Meade LX200 and Celestron NexStar compatible) The major changes of this version: Many changes in support of sky cultures Added 2 new plugins: Mosaic Camera and Custom Nebula Textures Many improvements in Core Updates in sky cultures (include new one) [full release notes] Download: Stellarium 25.2 (64-bit) | 361.0 MB (Open Source) View: Stellarium Home Page | Other Operating Systems | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Microsoft 365 Roadmap Weekly: Compact notifications in Teams, improvements to Copilot & more by David Uzondu It is the end of another week, which means there's a new batch of additions to the public Microsoft 365 Roadmap. Most of the additions this week were focused on the usual Microsoft products like Copilot, Edge, Teams, and Outlook. Let's start with Edge, because a change is coming to how the browser handles links from other apps, with an expected arrival in August. If you use different Edge profiles for work and personal stuff, you know the drill. Right now, your setting for a default profile takes priority. When this Edge update rolls out, an application like Teams or Outlook can recommend a profile, and Edge will prioritize that recommendation instead. An admin policy called "EdgeOpenExternalLinksWithAppSpecifiedProfile" will be available for organizations that want to control this behavior. Microsoft Teams is getting a few tweaks aimed at improving day-to-day use, spread out across this summer. Arriving next month, notifications are getting a compact mode, which shrinks them down for a more minimalist look on your screen. The ability to save messages and posts is also on the way for August. Teams will also get noise suppression for people who dial into meetings with a phone. It will automatically filter out background sounds like traffic or keyboard clatter, making calls clearer for everyone involved. This is set to roll out in September. If you spend too much time digging through old emails, an update for Outlook planned for next month should help. A new "Browse Conversation Files" feature will gather every file shared within an email thread into a single, easy-to-access view at the top of the conversation. Moving on to Copilot, the AI assistant will get one-click buttons to instantly generate FAQ or briefing pages from content in your Copilot Notebook. For managers, a new "scoped access" feature for the Copilot Dashboard will let them see adoption and usage stats just for their specific teams. Microsoft is also bringing the basic Copilot chat to its Department of Defense (DoD) customers next month, with web access turned off by default to "meet US Government requirements."
    • AMD power plans are not a thing anymore. That was their poor man's attempt to influence scheduling in Windows until they got Microsoft to update the scheduler to better understand the concepts of CCDs, which are super important to getting the correct performance form Ryzen. I never really understood how a power plan could have that effect, but I do know they are no longer needed.
    • I didn't measure it precisely, just clicked around a few things and noticed they mostly happened at that barely preservable amount of time, which I estimated to be around 0.25.
    • 'Animate controls and elements inside windows' affects the operation progress animations (e.g., when writing metadata to items) in Windows Vista; for example, this animation does not appear if that option is disabled: This little animation also does not animate in the Details Pane in Windows Explorer (or in the Welcome Center) if that option is disabled:
  • Recent Achievements

    • First Post
      Johnny Mrkvička earned a badge
      First Post
    • Week One Done
      viraltui earned a badge
      Week One Done
    • One Month Later
      serfegyed earned a badge
      One Month Later
    • Dedicated
      firey earned a badge
      Dedicated
    • Dedicated
      fettermanj earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      648
    2. 2
      Michael Scrip
      224
    3. 3
      ATLien_0
      222
    4. 4
      Xenon
      145
    5. 5
      +FloatingFatMan
      143
  • Tell a friend

    Love Neowin? Tell a friend!