Move bound column to right of dynamic column in datagrid?

J

John E.

I have a datatable that I am binding to a C# ASP.NET 1.1 web page datagrid.
I also
want to put an "Edit" column on the datagrid. However, whenever I use the
following code, it puts the Edit column on the left. I cannot figure out
how to get it to the right, as there is no DataGridTableStyle for ASP as
there is for an application.
I am doing the following on page load: (where dgItem is my datagrid):

EditCommandColumn editColumn = new EditCommandColumn();
editColumn.ButtonType = ButtonColumnType.LinkButton;
editColumn.CancelText = "Cancel";
editColumn.EditText = "Edit";
editColumn.HeaderText = "Edit";
editColumn.UpdateText = "Save";

dgItem.DataSource = ReturnsPopulatedDataTable();
dgItem.Columns.AddAt(1, editColumn);
/*also tried dgItem.Columns.AddAt(dgItem.Columns.Count, editColumn); without
success*/
dgItem.DataBind();

The edit column keeps showing up on the far left of the grid. Any ideas how
to get it to be added to the right side of the DataTable, instead?

Any help appreciated.
Thanks,

-John


xposted: microsoft.public.dotnet.framework.aspnet.datagrid 3/24/2005
 
M

masoud bayan

One guess:
are you using datagrid with *create columns automatically at run time
option* chosen? if so it generates those columns at run time after the fixed
columns. so you should disable it and assign columns at design time.

masoud
 
J

John E.

Thanks for the response! Yes, I have it set to create columns at runtime.
Is there a way to put the fixed columns to the right of runtime columns
instead of their default location on the left?

Thanks,
-John
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top