clear datagrid

  • Thread starter Thread starter Weeepie
  • Start date Start date
W

Weeepie

Hello,

Is it possible to clear a datagrid in VBdotNET?
I'm using a query to fill the datagrid, but when I change the parameter,
the next query follows the previous.
Is there someone who can help me.

Thx,

Weeepie.
 
Weepie:

I'm assuming you want to clear the datatable which will have the effect of
clearing the grid? To clear the datatable you can just call
DataTableName.Clear. So if you had 100 rows, then called .Clear, then in
the next query you called Fill again using the same Query you used the first
time (and just for example's sake, assume the data hasn't changed so you
should get the exact same results), then you'd have 100 rows now. Otherwise
with no Clear, you'd have 200 rows.

Remember that the grid is just the UI interface to the table and anything
done to a bound grid happens to the datasource.

On the other hand, if you really want to clear the datagird but not the
table, you'd need to clear the databindings but I don't think that's what
you are after.Let me know if it is.

Cheers,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
 
I'm gonna try.

Thx,
Weeepie.




William Ryan eMVP said:
Weepie:

I'm assuming you want to clear the datatable which will have the effect of
clearing the grid? To clear the datatable you can just call
DataTableName.Clear. So if you had 100 rows, then called .Clear, then in
the next query you called Fill again using the same Query you used the first
time (and just for example's sake, assume the data hasn't changed so you
should get the exact same results), then you'd have 100 rows now. Otherwise
with no Clear, you'd have 200 rows.

Remember that the grid is just the UI interface to the table and anything
done to a bound grid happens to the datasource.

On the other hand, if you really want to clear the datagird but not the
table, you'd need to clear the databindings but I don't think that's what
you are after.Let me know if it is.

Cheers,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
 
It works,

Thanks




William Ryan eMVP said:
Weepie:

I'm assuming you want to clear the datatable which will have the effect of
clearing the grid? To clear the datatable you can just call
DataTableName.Clear. So if you had 100 rows, then called .Clear, then in
the next query you called Fill again using the same Query you used the first
time (and just for example's sake, assume the data hasn't changed so you
should get the exact same results), then you'd have 100 rows now. Otherwise
with no Clear, you'd have 200 rows.

Remember that the grid is just the UI interface to the table and anything
done to a bound grid happens to the datasource.

On the other hand, if you really want to clear the datagird but not the
table, you'd need to clear the databindings but I don't think that's what
you are after.Let me know if it is.

Cheers,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
 
Hi Weeepie,

If you want to completly disconnect your datagrid from the dataset and run different table with datagrid then,
you will have to do the following

Datagrid.DataSource = Nothing

However, you are just changing the parameter, so I presume you are using the same table.

Assuming that your query results were filled to dataset "objdsTest" and the datagrid was mapped to table name "Tempy", then..

Me.objdsTest.Tempy.Clear()

The line above will clear the data in dataset and so for the next query all you have to do is fill it in again.

' need your SQL command with different parameters first.
Me.daTempy.Fill(objdsTest)

I hope this was the solution for your problem.

**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
Back
Top