Problem Soring DataGrid using BoundColumns

G

Guest

I am adding boundColumns to my DataGrid via code-behind using the following
code:

BoundColumn bc = new BoundColumn();
bc.HeaderText = "Users";
bc.DataField = "vUserId";
bc.SortExpression = "vUserId";
dg_Users.Columns.AddAt(0, bc);

The boundColumns are added fine, along w/ the rest of the columns in my
datatable. However, when i set the AutoGenerateColumns property to false so
that only the BoundColumns show, the SortCommand no longer fires:

dg_Users.AllowPaging = true;
dg_Users.PageSize = 2;
dg_Users.DataKeyField = "vUserId";
dg_Users.AllowSorting = true;
dg_Users.AutoGenerateColumns = false;

The SortCommand is wired in the InitializeComponent method as follows:

this.dg_Users.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.SortCommand);

Any ideas? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top