7 Replies - 42806 Views - Last Post: 01 June 2009 - 07:54 AM Rate Topic: -----

#1 kunkka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 99
  • Joined: 15-May 09

how to clear datagridview

Posted 28 May 2009 - 05:26 AM

when datagridview fills with data. how to clear them

can somone help
Is This A Good Question/Topic? 0
  • +

Replies To: how to clear datagridview

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: how to clear datagridview

Posted 28 May 2009 - 05:34 AM

DatagridView1.Rows.Clear()

This post has been edited by noorahmad: 28 May 2009 - 05:35 AM

Was This Post Helpful? 0
  • +
  • -

#3 kunkka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 99
  • Joined: 15-May 09

Re: how to clear datagridview

Posted 28 May 2009 - 05:47 AM

it says cannot clear the list

ArgumentException was unheld

y is that

it says cannot clear the list

ArgumentException was unhandled

y is that
Was This Post Helpful? 0
  • +
  • -

#4 kunkka  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 99
  • Joined: 15-May 09

Re: how to clear datagridview

Posted 28 May 2009 - 06:28 AM

i got a good solution

u can clear by

DatagridviewName.DataSource=Nothing
Was This Post Helpful? 0
  • +
  • -

#5 eworm  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 64
  • Joined: 17-March 09

Re: how to clear datagridview

Posted 28 May 2009 - 01:29 PM

Can you post the code you are using?

I use DataGridView1.Rows.Clear at least 20 times throughout my current program and it's working fine.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13655
  • View blog
  • Posts: 54,482
  • Joined: 12-June 08

Re: how to clear datagridview

Posted 28 May 2009 - 08:16 PM

Just clear the dataset table that the gridview data comes from...

You *are* setting your dataview to pull from a dataset, right?
Was This Post Helpful? 0
  • +
  • -

#7 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: how to clear datagridview

Posted 31 May 2009 - 11:03 PM

View Postkunkka, on 28 May, 2009 - 04:17 PM, said:

it says cannot clear the list

ArgumentException was unheld

y is that

it says cannot clear the list

ArgumentException was unhandled

y is that



View Postkunkka, on 28 May, 2009 - 04:58 PM, said:

i got a good solution

u can clear by

DatagridviewName.DataSource=Nothing


nice work, when the datagrideview is fill from a datatable or dataset then we are using this funciton.
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13655
  • View blog
  • Posts: 54,482
  • Joined: 12-June 08

Re: how to clear datagridview

Posted 01 June 2009 - 07:54 AM

View Postnoorahmad, on 1 Jun, 2009 - 12:03 AM, said:

View Postkunkka, on 28 May, 2009 - 04:17 PM, said:

it says cannot clear the list

ArgumentException was unheld

y is that

it says cannot clear the list

ArgumentException was unhandled

y is that



View Postkunkka, on 28 May, 2009 - 04:58 PM, said:

i got a good solution

u can clear by

DatagridviewName.DataSource=Nothing


nice work, when the datagrideview is fill from a datatable or dataset then we are using this funciton.


making the datagridview's datasource 'nothing' seems like a bad idea. Just clear the data table in the first place.

if:
<your datagrid>.datasource = myDataSet
<your datagrid>.datamember = <table name>

then to clear it just clear the table: myDataSet.<table name>.clear()
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1