Tutorials
Resources
Forum
Interview
Jobs
Projects
Offshore Development
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Revenue Sharing
|
Talk to Us
|
My Profile
Sign In
Register
AdSense Revenue
Gifts
Active Members
Today
Athira Appukut...
(278)
vipul
(175)
D.Jeya kumar(J...
(143)
Last 7 Days
Athira Appukut...
(1737)
D.Jeya kumar(J...
(1341)
Sridhar R
(1336)
more...
Creating dynamic template columns in gridview
Posted Date: 23 Jun 2008 Resource Type:
Code Snippets
Category:
ASP.NET GridView
Posted By:
shakti singh tanwar
Member Level:
Diamond
Rating:
Points
: 5
Dataset ds = getDataset(); // Some function to retrieve data
DataTable dt = ds.Tables[o];
for ( int i=1 ; i <= dt.Columns.Count -1 ; i++)//Loop through columns collection
{
// Creating Template Column
TemplateColumn templateColumn = new TemplateColumn();
string columnName = dt.Columns[i].ColumnName;
templateColumn.HeaderTemplate = new DataGridTemplate(ListItemType.Header,columnName);
// Adding the Rows to the DataGrid
for ( int j=0; j<= dt.Rows.Count - 1 ; j++)
{
string value= dt.Rows[j][i].ToString();
templateColumn.ItemTemplate = new DataGridTemplate(ListItemType.Item,value);
}
myDataGrid.Columns.Add(templateColumn);
}
Responses
Author:
Roshan R Mhatre
23 Jul 2008
Member Level:
Gold
Points
: 1
Its not working..
it gives error to
Dataset ds = getDataset(); // Some function to retrieve data
DataTable dt = ds.Tables[o];
myDataGrid.Columns.Add(templateColumn);
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
(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:
Creating dynamic bound columns
Previous Resource:
paging, sorting, link button in GridView
Return to Discussion Resource Index
Post New Resource
Category:
ASP.NET GridView
Post resources and
earn money
!
Related Resources
Exporting Data From GridView/DataSet to Word/Excel
GridView Tips and Tricks using ASP.NET 2.0
Exporting DataGrid to Excel in c#
Dynamically adding columns to the GridView control
DropDownList controls in a Gridview
dotNet Slackers
BizTalk Adaptors
Web Design
doors in nj
Contact Us
Privacy Policy
Terms Of Use