Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Datagrid -Last row always blank for add new record

Datagrid -Last row always blank for add new record

Scheduled Pinned Locked Moved Visual Basic
csharphelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 2232424
    wrote on last edited by
    #1

    Hello, i am beginner in vb.net. I know well how to bind the data in a datagrid.Now i want to add a new record in to a table through datagrid thats why in my datagrid last row is always blank. How it is possible? How to enter new record in a datagrid? Any one know the solution help me. aruljothi

    M 1 Reply Last reply
    0
    • U User 2232424

      Hello, i am beginner in vb.net. I know well how to bind the data in a datagrid.Now i want to add a new record in to a table through datagrid thats why in my datagrid last row is always blank. How it is possible? How to enter new record in a datagrid? Any one know the solution help me. aruljothi

      M Offline
      M Offline
      Mandar Patankar
      wrote on last edited by
      #2

      what you need to do is add rows dynamically to the table source of the datagrid for eg:- you have a material table as a datasource to your datagrid.Now you dynamically add rows to this table.The rows added are material detail selected by user. the user selects specific material from the drop down combobox here is a sample code snippet Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click Dim drow As DataRow = material.NewRow Dim drv As DataRowView = CType(cmbmatnam.SelectedItem, DataRowView) Try drow("column1") = drv("mat_id") drow("Column2") = drv("mat_name") drow("Column3") = drv("Rate") drow("Column4") = drv("Quantity") drow("Column6") = "Enter Quantity" material.Rows.Add(drow) material.AcceptChanges() Catch ex1 As System.NullReferenceException MessageBox.Show("There are No Materials In this Category") Catch ex2 As System.Data.ConstraintException MessageBox.Show("Material Is already Selected") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub I hope this helps Mandar Patankar Microsoft Certified professional

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups