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 !






Creating dynamic bound columns


Posted Date: 23 Jun 2008    Resource Type: Code Snippets    Category: ASP.NET GridView
Author: shakti singh tanwarMember Level: Diamond    
Rating: Points: 5




DataSet ds = getDataset(); //Some function to retrieve data into dataset

// Create Bound Columns
BoundColumn columnName = new BoundColumn();

columnName.HeaderText = "SomeName"; //Set header text

columnName.DataField = "ColumnNameToBindInDataSource"; //Set bound column

myDataGridView.Columns.Add(columnName); //Add column to gridview

myDataGridView.DataSource = ds;

myDataGridView.DataBind();




Responses

Author: angel    22 Dec 2008Member Level: Bronze   Points : 2
hi i pasted this code in button click but iam getting an error...
i removed that function and wrote
dataset ds=new dataset();

Error 1 The best overloaded method match for 'System.Web.UI.WebControls.DataControlFieldCollection.Add(System.Web.UI.WebControls.DataControlField)' has some invalid arguments F:\logincontrols\Default.aspx.cs 33 9 F:\logincontrols\

this is the error iam getting


Author: angel    22 Dec 2008Member Level: Bronze   Points : 1
Error 2 Argument '1': cannot convert from 'System.Web.UI.WebControls.BoundColumn' to 'System.Web.UI.WebControls.DataControlField' F:\logincontrols\Default.aspx.cs 33 31 F:\logincontrols\


and this one


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: Nested Gridview with Checkbox Column
Previous Resource: Creating dynamic template columns in gridview
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET GridView


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use