• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Clear data in the datagrid

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
Jassimi
Asked:
Jassimi
  • 3
  • 2
1 Solution
 
srikanthreddyn143Commented:
GView.DataSource = Nothing
gView.DataBind()
0
 
RamanaChoudaryCommented:
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
 
JassimiAuthor Commented:
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
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.

 
srikanthreddyn143Commented:
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
 
JassimiAuthor Commented:
can you write full statement ?
0
 
JassimiAuthor Commented:
Ok...
I got the solution,

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

Thanks


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now