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 !




Adding new column to datatable


Posted Date: 06 Jun 2008    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: Kumar VeluMember Level: Diamond    
Rating: Points: 8



Following code helps to add new column to datatable:

//page load
.
.
DataTable dt2 = new DataTable();
DataColumn col;
col = new DataColumn("empid", System.Type.GetType(" System.Int32"));
//add this column empid into datatable dt2
dt2.Columns.Add(col);
col = new DataColumn("empname", System.Type.GetType("System.String"));
dt2.Columns.Add(col);
col = new DataColumn("Remarks", System.Type.GetType("System.String"));
dt2.Columns.Add(col);
col = new DataColumn("Country", System.Type.GetType(" System.Int32"));
dt2.Columns.Add(col);

dt2.AcceptChanges();

Gridview1.Datasorce=dt2;//binding the data table to gridview
Gridview1.Databind();




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: How Dynamically Insert Javascript into Asp.net
Previous Resource: List Environment Variables at Server using ASP.NET
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use