.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Add Bound Field in Gridview Control at Runtime

Posted By:varun bansal       Posted Date: July 28, 2009    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  
 

Add Bound Field in Gridview Control at  Runtime. First of all you have to set the gridview with two bounded column like (name,age)
now if u want to add new column bounded column dob at the run time then follow this code..

protected void Button1_Click(object sender, EventArgs e)

{

BoundField boundField = new BoundField();

boundField.DataField = "DOB";

boundField.HeaderText = "DOB";

boundField.HtmlEncode = false;

boundField.DataFormatString = "{0:d}";

GridView1.Columns.Add(boundField);

//bind gridview..



bindgridview();

}


note: data source must contain the dob column...
(i.e. dataset,datatable, datareader and so on)

Regard
Varun Bansal
www.varunbansal007.blogspot.com

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend