[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Clear data in the datagrid

Posted on 2009-05-19
6
Medium Priority
?
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 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