Clear Datagridview - Daniweb

clear datagridview vb.net
  1. Home
  2. Programming Forum
  3. Software Development Forum
  4. Discussion / Question
Member Avatar for geoamins2

Could you please tell me how to clear the old data from the datagridview in vb.net.. the below code is retrieving the data from table and display in a gridview for particular person. but when i wanna check the next person record if he dosen't have record so the previous data still will not erased?

Dim c As New sqlStmt c.myCon() Dim da As New SqlDataAdapter("SELECT * FROM Experience WHERE CID='" & Trim(txtCID.Text) & "'", c.con) Dim ds As New DataSet("ManPower") da.Fill(ds, "ManPower") dgExperience.DataSource = ds.Tables("ManPower").DefaultView vb.net 0 0 Share
  • 4 Contributors
  • 3 Replies
  • 5K Views
  • 3 Days Discussion Span
  • Latest Post 12 Years Ago Latest Post by pritesh2010
Member Avatar for lolafuertes

Did you refresh the dgExperience after assigning the data source?

dgExperience.Refresh

Also the

dgExperience.Rows.Clear

before assigning the new data source, can help.

Hope this helps

0 0 Share Member Avatar for M.Waqas Aslam

hi ! try this code

datagridview1.rows.clear()

it will remove all the rows then assign new data to it Regards Hope this will helps u

Regards . M.Waqas Aslam

0 0 Share Member Avatar for pritesh2010 //whenever you are trying to bind DataTable to Datagridview //First of all make Datagridview datasource null; //set the dgExperience.DataSource = null // then write your code // and even you can check your DataTable Like DataTable _DataTable=new DataTable(); if( _DataTable!=null || _DataTable.Rows.Count !=0) then // bind your grid with datatable or dataset else dgExperience.DataSource = null 0 0 Share Edited 12 Years Ago by pritesh2010 because: n/a Share Facebook Twitter LinkedIn Reply to this topic Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.

Sign Up — It's Free! Related Topics
  • Member Avatar how to work with master details in unbound datagridview vb.net 2
  • Member Avatar Filtering Date in DataGridView VB.NET 6
  • Member Avatar execution problem 6
  • Member Avatar Export to Excal from DataGridView Vb.Net 1
  • Member Avatar count smaller in assembly language MASM615 2
  • Member Avatar add checkbox in multiple rows runtime datagridview vb.net 2010 2
  • Member Avatar Vectors in java? 8
  • Member Avatar DataGridView doesn't refresh after insert data 3
  • Member Avatar Copy a Folder 14
  • Member Avatar VB.Net 2008 Print DataGridView (Text Wrap top header column and lock in width) 3
  • Member Avatar Question about jDateChooser.. Help please :) 1
  • Member Avatar VB.Net 2008 Save Print Preview DataGridView inside txt file or Excel 1
  • Member Avatar problem with c# validation of user input 2
  • Member Avatar datagridview 2 related comboboxes issue 1
  • Member Avatar Make a bot that fills in information on websites 9
  • Member Avatar VB.NET ADO bound combobox issue 4
  • Member Avatar Classes and object in c # 2
  • Member Avatar VB.Net DataGridView Cell Editable 2
  • Member Avatar DataGridView Filter XML Data 3
  • Member Avatar VB.Net splitting a streamreader string in VB.Net 4
Not what you need?

Reach out to all the awesome people in our software development community by starting your own topic. We equally welcome both specific questions as well as open-ended discussions.

Start New Topic Topics Feed Reply to this Topic Edit Preview Message H1 H2 Post Reply

Share Post

Permanent Link Facebook Facebook Twitter Twitter LinkedIn LinkedIn

Insert Code Block

Insert Code Block Search Search
  • Forum Categories
  • Hardware/Software
    • Recommended Topics
  • Programming
    • Recommended Topics
  • Digital Media
    • Recommended Topics
  • Community Center
    • Recommended Topics
  • Latest Content
  • Newest Topics
  • Latest Topics
  • Latest Posts
  • Latest Comments
  • Top Tags
  • Topics Feed
  • Social
  • Forums
  • Top Members
  • Meet People
  • Community Functions
  • DaniWeb Premium
  • Newsletter Archive
  • Markdown Syntax
  • Community Rules
  • Developer APIs
  • Connect API
  • Forum API Docs
  • Tools
  • SEO Backlink Checker
  • Legal
  • Terms of Service
  • Privacy Policy
  • FAQ
  • About Us
  • Advertise
  • Contact Us
© 2024 DaniWeb® LLC

Từ khóa » Visual Basic Clear Gridview