Solved

Clear data in the datagrid

Posted on 2009-05-19
6
183 Views
Last Modified: 2012-05-07
Hi..
I have a datagrid that contains on data,
these data has come from database table,

how can I clear this datagrid from its data and leave the column headers only

thanks
0
Comment
Question by:Jassimi
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24421708
GView.DataSource = Nothing
gView.DataBind()
0
 
LVL 4

Expert Comment

by:RamanaChoudary
ID: 24423182
You can add columns(for Headers) manually in DataGridView then bind with data table columns
then
DataGridView1.DataSource = Nothing
or paste u r code i can modify and send to u back...
0
 
LVL 2

Author Comment

by:Jassimi
ID: 24438547
srikanthreddyn143

I know your method.. but like this will clear the whole grid with the headers..
I don't want to remove the headers... I want to clear the data only...

RamanaChoudary

I don't want to make it manualy... I want it by code

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24442103
Then write a dummy sql code with all ur columns and make where condition as "where 1= 0'  

wgich returns columns with out data
0
 
LVL 2

Author Comment

by:Jassimi
ID: 24449181
can you write full statement ?
0
 
LVL 2

Accepted Solution

by:
Jassimi earned 0 total points
ID: 24449914
Ok...
I got the solution,

We have to Set the DataTable clear:
DataTable.Clear()

Thanks


0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question