C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




clear rows from datagridview


Posted Date: 05 Sep 2008      Total Responses: 4

Posted By: kalees       Member Level: Bronze     Points: 1



Hi ,

I am binding datasourse with datagridview.

Now i want to clear rows but i need header text.

When i give datasourse =Nothing ,header also gone.

When i use dgv.rows.clear() , getting error.

How to do this ?

Thanks in Advance

Kalees





Responses

Author: Arunagiri Gunasekaran    05 Sep 2008Member Level: GoldRating:     Points: 2

Hi,
Try like this.

First move that data source to the dataview and use row filter

For example,

DataTable dt_Details = new DataTable();
dt_Details = //Fill the content
DataView dv = new DataView(dt_Details);
dv.RowFilter = "1 = 2";// this is avoid all the rows from the dataview

dgv.DataSource = dv;
dgv.DataBind();

Here the dataview will not contain any records. Because '1=2' never satisfy to get the records. Hence the DataView contains only the structure but not the records. And so you will get the gridview with header alone.

All the Best :)



Author: ramya    05 Sep 2008Member Level: GoldRating:     Points: 2

if u have taken dataset and filled the gridview then try dis


ds.tables.clear(); (or) ds.rows.clear()



Author: kalees    05 Sep 2008Member Level: BronzeRating:     Points: 1

Hi Arunagiri Gunasekaran

I dont have the dataset after binding to the gridview .. i make it as null ... when i click clear button i have to clear rows...



Author: Divakar S    08 Sep 2008Member Level: GoldRating:     Points: 3

Try this it will help u

dv.Table.Rows.Clear();
dataGridView1.DataSource = dv;

or

try this

select * from tablename where 1=0



Post Reply
You must Sign In to post a response.
Next : Not able to see Image in tree view file..
Previous : PictureBox image size
Return to Discussion Forum
Post New Message
Category: Windows

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use