Solved

Clear data in the datagrid

Posted on 2009-05-19
6
174 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
Comment Utility
GView.DataSource = Nothing
gView.DataBind()
0
 
LVL 4

Expert Comment

by:RamanaChoudary
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Expert Comment

by:srikanthreddyn143
Comment Utility
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
Comment Utility
can you write full statement ?
0
 
LVL 2

Accepted Solution

by:
Jassimi earned 0 total points
Comment Utility
Ok...
I got the solution,

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

Thanks


0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now