Solved

Clear data in the datagrid

Posted on 2009-05-19
6
185 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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