471,853 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,853 software developers and data experts.

Dynamically add button column to DataGrid

Hi everyone, I'm trying to dynamically add 3 button columns to a
DataGrid object that I have on an ASP.net webpage, but I don't see any
documentation on how to do it. I've seen plenty of examples on how to
add regular columns, but how do you declare a button column? My code is
posted below, I have a placeholder on a webform, and the datagrid will
be added on the placeholder once it is initalised. Thanks!

System.Web.UI.WebControls.Label lblNoRecords = new

clsResults objResults = new clsResults();

objResults.SourceWebPage = this;
objResults.SQLString = sSQLString;

// Set datagrid reference to returned results
this.dgTable = objResults.DataGrid;

// Add button columns to datagrid
DataColumn editButton = ???
DataColumn updateButton = ???
DataColumn cancelButton = ???
// Add event handlers
this.dgTable.EditCommand += new
this.dgTable.CancelCommand += new
DataGridCommandEventHandler(dgTable_CancelCommand) ;
this.dgTable.UpdateCommand += new
DataGridCommandEventHandler(dgTable_UpdateCommand) ;

// Add datagrid to webform

if (objResults.RecordsRetrieved == 0)
lblNoRecords.Text = "No records retrieved from database";
lblNoRecords.CssClass = "norecordsText";

objResults = null;

Jun 12 '06 #1
0 1714

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by John Ruiz | last post: by
4 posts views Thread by bill | last post: by
3 posts views Thread by david | last post: by
4 posts views Thread by sydney.luu | last post: by
reply views Thread by herman404 | last post: by
4 posts views Thread by Craig Buchanan | last post: by
reply views Thread by NeoPa | last post: by
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.