• 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

    • They always have. This just updates what's included out of the box during the initial install.
    • So basically their prebuilding it into the ISOs?
    • Microsoft shares Defender anti-virus update for new Windows 11/10 ISOs by Sayan Sen Following the one for Lumma last month, Microsoft has also published a new Defender update for Windows 11/10/Server installation images this month. This update package is necessary as a Windows installation image may contain old, outdated anti-malware definitions and software binaries. Aside from better security, these updates can also provide improved performance benefits in some cases. When a new Windows installation is set up, there may be a temporary security risk due to outdated Microsoft Defender protection in the OS installation images. This happens because the antimalware software included in these images might not be up to date. Thus Microsoft says that these updated definitions essentially help close this protection gap. Microsoft delivered the latest security definitions for Windows images via security intelligence update version 1.431.54.0. The Defender package version is also the same. It applies to Windows 11, Windows 10 (Enterprise, Pro, and Home editions), Windows Server 2022, Windows Server 2019, and Windows Server 2016. Microsoft writes: From Microsoft's security bulletin, we learn that the security intelligence update version 1.431.54.0 was released this past week adds threat detections for various backdoor exploits, trojans, among others. For those wondering, the latest intelligence update is version 1.431.155.0 at the time of writing.
    • “In other news about OneDrive frustration, Microsoft recently locked out a user who was attempting to move a bunch of important data from old hard drives to OneDrive.” - It was probably CSMA..
    • Just what I needed! An extremely expensive pair of sunglasses that I will lose and cannot use indoors. My life will be complete. I trust Meta AI watching my entire life happen. It's going to be the best ever!
  • Recent Achievements

    • One Month Later
      SekTheFirst earned a badge
      One Month Later
    • First Post
      zayanhani earned a badge
      First Post
    • First Post
      HarryTaylor earned a badge
      First Post
    • One Year In
      Eternal Tech earned a badge
      One Year In
    • One Month Later
      Eternal Tech earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      650
    2. 2
      ATLien_0
      232
    3. 3
      Michael Scrip
      224
    4. 4
      +FloatingFatMan
      140
    5. 5
      Steven P.
      140
  • Tell a friend

    Love Neowin? Tell a friend!