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 !




Insert a blank row at a particular position in a datagrid


Posted Date: 21 Feb 2007    Resource Type: Code Snippets    Category: Winforms DataGrid

Posted By: Mathews . T. Varghese       Member Level: Gold
Rating:     Points: 10



Normally we get data from a database in a DataSet or DataTable which is then assigned as the datasource for the datagrid. If we want to display something in the datagrid which we dont want to enter into the database the we have to edit the DataSet or DataTable. Below given is a way to edit a DataTable so as to enter an extra row into it.



//Create the DataTable
DataTable dt = new DataTable();

//Creating a blank row
DataRow BlankRow = dt.NewRow();

//Insert the columns
BlankRow[ "PlantName" ] = Plant;
BlankRow[ "Capital"] = Capital;

//Insert the row at the desired place
dt.Rows.InsertAt ( BlankRow, dt.Rows.Count + 1 );

//exception
//you can also insert the columns with blank data
BlankRow[ "PlantName" ] = "";
BlankRow[ "Capital"] = "";




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Change the color of a datagrid column based on the value in that column
Previous Resource: Validate a column in DataGridView
Return to Discussion Resource Index
Post New Resource
Category: Winforms DataGrid


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

teleconferencing service

Contact Us    Privacy Policy    Terms Of Use